Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronwolen committed Jan 23, 2020
1 parent 53b928c commit 80766a2
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion R/osf_upload.R
Expand Up @@ -2,7 +2,7 @@
#'
#' Upload local files to a project, component, or directory on OSF.
#'
#' @param x The upload destintation on OSF. Can be one of the following:
#' @param x The upload destination on OSF. Can be one of the following:
#' * An [`osf_tbl_node`] with a single project or component.
#' * An [`osf_tbl_file`] with a single directory.
#' @param path A character vector of paths pointing to existing
Expand Down
2 changes: 1 addition & 1 deletion man-roxygen/synchronization.R
Expand Up @@ -5,5 +5,5 @@
#' something like [`rsync`](https://rsync.samba.org),
#' `osf_download()`/`osf_upload()` do not take into account a file's contents or
#' modification time. Whether you're uploading or downloading, if `overwrite =
#' TRUE`, osfr will overwrite an existing file regradless of whether the
#' TRUE`, osfr will overwrite an existing file regardless of whether the
#' existing file is the more recent copy. You have been warned.
2 changes: 1 addition & 1 deletion man/osf_download.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/osf_upload.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/spelling.R
@@ -1,3 +1,3 @@
if (requireNamespace("spelling", quietly = TRUE)) {
spelling::spell_check_test(vignettes = TRUE, error = FALSE, skip_on_cran = TRUE)
}
if(requireNamespace('spelling', quietly = TRUE))
spelling::spell_check_test(vignettes = TRUE, error = FALSE,
skip_on_cran = TRUE)
38 changes: 19 additions & 19 deletions vignettes/getting_started.Rmd
Expand Up @@ -87,13 +87,13 @@ We can also download local copies of these files by passing `anes_files` to `osf
```r
osf_download(anes_files)
#> # A tibble: 5 x 4
#> name id local_path meta
#> <chr> <chr> <chr> <list>
#> 1 cleaning.R 5e20d22bedceab002d82e0f1 ./cleaning.R <named list [3
#> 2 Questionnaire.docx 5e20d22bedceab002b82dc3f ./Questionnaire.docx <named list [3
#> 3 raw_data.csv 5e20d22c675e0e00096b4de8 ./raw_data.csv <named list [3
#> 4 Data Dictionary.docx 5e20d22c675e0e000e6b4b18 ./Data Dictionary.docx <named list [3
#> 5 analyses.R 5e20d22c675e0e000a6b4bd3 ./analyses.R <named list [3
#> name id local_path meta
#> <chr> <chr> <chr> <list>
#> 1 cleaning.R 5e20d22bedceab002d82e0f1 ./cleaning.R <named list [3]>
#> 2 Questionnaire.docx 5e20d22bedceab002b82dc3f ./Questionnaire.docx <named list [3]>
#> 3 raw_data.csv 5e20d22c675e0e00096b4de8 ./raw_data.csv <named list [3]>
#> 4 Data Dictionary.docx 5e20d22c675e0e000e6b4b18 ./Data Dictionary.docx <named list [3]>
#> 5 analyses.R 5e20d22c675e0e000a6b4bd3 ./analyses.R <named list [3]>
```

We'll use these files in the next section for creating a new project.
Expand Down Expand Up @@ -129,10 +129,10 @@ my_project
#> # A tibble: 1 x 3
#> name id meta
#> <chr> <chr> <list>
#> 1 Political Identification and Gender: Re-examined tr5x2 <named list [3]>
#> 1 Political Identification and Gender: Re-examined 9e6kv <named list [3]>
```

The GUID for this new project is tr5x2, but yours will be something different. You can check out the project on OSF by opening it's URL (`https://www.osf.io/<GUID>`), or, more conveniently: `osf_open(my_project)`.
The GUID for this new project is 9e6kv, but yours will be something different. You can check out the project on OSF by opening it's URL (`https://www.osf.io/<GUID>`), or, more conveniently: `osf_open(my_project)`.

### Adding structure with components

Expand Down Expand Up @@ -162,7 +162,7 @@ data_file
#> # A tibble: 1 x 3
#> name id meta
#> <chr> <chr> <list>
#> 1 raw_data.csv 5e29d03bc19c5d006dedf2d0 <named list [3]>
#> 1 raw_data.csv 5e29f7af87a1d9007a1cdcb6 <named list [3]>
```

Oh no! Instead of uploading `raw_data.csv` to the *Raw Data* component, we uploaded it to the parent project instead.
Expand All @@ -185,9 +185,9 @@ r_files
#> # A tibble: 3 x 3
#> name id meta
#> <chr> <chr> <list>
#> 1 analyses.R 5e29d04087a1d9005f1cdf7d <named list [3]>
#> 2 cleaning.R 5e29d04387a1d9005f1cdf84 <named list [3]>
#> 3 precompile.R 5e29d046c19c5d006dedf2e1 <named list [3]>
#> 1 analyses.R 5e29f7b487a1d900761ce601 <named list [3]>
#> 2 cleaning.R 5e29f7b6c19c5d0080ee0246 <named list [3]>
#> 3 precompile.R 5e29f7b9c19c5d0082edff21 <named list [3]>
```

### Putting it all together
Expand All @@ -202,8 +202,8 @@ my_project %>%
#> # A tibble: 2 x 3
#> name id meta
#> <chr> <chr> <list>
#> 1 Data Dictionary.docx 5e29d04bc19c5d006dedf2ed <named list [3]>
#> 2 Questionnaire.docx 5e29d04d87a1d900511cfd18 <named list [3]>
#> 1 Data Dictionary.docx 5e29f7bdc19c5d007eedfe04 <named list [3]>
#> 2 Questionnaire.docx 5e29f7bfc19c5d007eedfe08 <named list [3]>
```

We can verify the project is now structured the way we wanted by listing the components we have under the main project.
Expand All @@ -214,9 +214,9 @@ osf_ls_nodes(my_project)
#> # A tibble: 3 x 3
#> name id meta
#> <chr> <chr> <list>
#> 1 Research Materials 6w2sd <named list [3]>
#> 2 Analysis Scripts 6egc3 <named list [3]>
#> 3 Raw Data uxjwh <named list [3]>
#> 1 Research Materials 6k2j4 <named list [3]>
#> 2 Analysis Scripts 324a7 <named list [3]>
#> 3 Raw Data q2ms4 <named list [3]>
```

which gives us an `osf_tbl` with one row for each of the project's components.
Expand Down Expand Up @@ -247,7 +247,7 @@ Learn more about file versioning on OSF [here][osf-versioning].

### Sharing

Remember, new OFS projects are *always* private by default. You can change this by opening the project's settings page on OSF and making it public. See the following guides more information about OSF permissions and how to optionally generate a DOI so other can cite your project.
Remember, new OSF projects are *always* private by default. You can change this by opening the project's settings page on OSF and making it public. See the following guides more information about OSF permissions and how to optionally generate a DOI so other can cite your project.

* [Privacy Settings][osf-privacy]
* [Sharing Projects][osf-sharing]
Expand Down
32 changes: 16 additions & 16 deletions vignettes/getting_started.Rmd.orig
@@ -1,7 +1,7 @@
---
title: "Getting Started with osfr"
date: "`r Sys.Date()`"
output:
output:
rmarkdown::html_vignette:
toc: TRUE
vignette: >
Expand All @@ -17,7 +17,7 @@ knitr::opts_chunk$set(
)
```

This vignette provides a quick tour of the *osfr* package.
This vignette provides a quick tour of the *osfr* package.

```{r message=FALSE}
library(osfr)
Expand All @@ -29,9 +29,9 @@ library(osfr)
osfr:::osf_dev_off()
```

## What is OSF?
## What is OSF?

[OSF][osf] is a free and open source web application that provides a space for researchers to collaboratively store, manage, and share their research materials (e.g. data, code, protocols).
[OSF][osf] is a free and open source web application that provides a space for researchers to collaboratively store, manage, and share their research materials (e.g. data, code, protocols).

Most work on OSF is organized around ***projects***, which include a cloud-based storage bucket where files can be stored and organized into directories. Note there is no storage limit on the size of projects but individual files must be < 5Gb. Projects can be kept private, shared with a specific group of collaborators, or made publicly available with citable DOIs so you can get credit for their work.

Expand All @@ -44,7 +44,7 @@ Here are a few relevant topics:

## Accessing OSF projects

Let's check out an example project containing materials for an analysis of the 2012 American National Election Survey (ANES). You can access the OSF project in your browser by navigating to its URL: <https://osf.io/jgyxm/>.
Let's check out an example project containing materials for an analysis of the 2012 American National Election Survey (ANES). You can access the OSF project in your browser by navigating to its URL: <https://osf.io/jgyxm/>.

Let's load this project into R with `osfr::osf_retrieve_node()`:

Expand All @@ -53,7 +53,7 @@ anes_project <- osf_retrieve_node("https://osf.io/jgyxm")
anes_project
```

This returns an `osf_tbl` object, which is the `data.frame`-like class *osfr* uses to represent items retrieved from OSF. You can now use `anes_project` to perform a variety of project related tasks by passing it to different osfr functions.
This returns an `osf_tbl` object, which is the `data.frame`-like class *osfr* uses to represent items retrieved from OSF. You can now use `anes_project` to perform a variety of project related tasks by passing it to different osfr functions.

### Downloading files

Expand All @@ -74,7 +74,7 @@ Because `osf_tbl`s are just specialized `data.frame`s, we could also `subset()`

*__Note:__ If an `osf_tbl` with multiple entities is passed to an non-vectorized osfr function like `osf_open()`, the default behavior is to use the entity in the first row and warn that all other entities are ignored.*

We can also download local copies of these files by passing `anes_files` to `osf_download()`.
We can also download local copies of these files by passing `anes_files` to `osf_download()`.

```{r}
osf_download(anes_files)
Expand All @@ -89,8 +89,8 @@ As you've likely noticed, `osf_tbl` objects are central to osfr's functionality.
Here is a short example that consolidates all of the steps we've performed so far:

```{r, eval=FALSE}
osf_retrieve_node("jgyxm") %>%
osf_ls_files() %>%
osf_retrieve_node("jgyxm") %>%
osf_ls_files() %>%
osf_download()
```

Expand All @@ -114,9 +114,9 @@ The GUID for this new project is `r my_project$id`, but yours will be something

### Adding structure with components

A key organizational feature of OSF is the ability to augment a project's structure with sub-projects, which are referred to as *components* on OSF. Like top-level projects, every component is assigned a unique URL and contains its own cloud-based storage bucket. They can also have different privacy settings from the parent project.
A key organizational feature of OSF is the ability to augment a project's structure with sub-projects, which are referred to as *components* on OSF. Like top-level projects, every component is assigned a unique URL and contains its own cloud-based storage bucket. They can also have different privacy settings from the parent project.

We are going to create two nested *components*, one for the raw data and one for the analysis scripts.
We are going to create two nested *components*, one for the raw data and one for the analysis scripts.

```{r}
data_comp <- osf_create_component(my_project, title = "Raw Data")
Expand All @@ -137,15 +137,15 @@ data_file <- osf_upload(my_project, path = "raw_data.csv")
data_file
```

Oh no! Instead of uploading `raw_data.csv` to the *Raw Data* component, we uploaded it to the parent project instead.
Oh no! Instead of uploading `raw_data.csv` to the *Raw Data* component, we uploaded it to the parent project instead.

Fear not. We can easily fix this contrived mistake by simply moving the file to its intended location.

```{r}
data_file <- osf_mv(data_file, to = data_comp)
```

Crisis averted. Now if you open *Raw Data* on OSF (`osf_open(data_comp)`), it should contain the csv file.
Crisis averted. Now if you open *Raw Data* on OSF (`osf_open(data_comp)`), it should contain the csv file.

Our next step is to upload the R scripts into the *Analysis Scripts* component. Rather than upload each file individually, we'll take advantage of `osf_upload()`'s ability to handle multiple files/directories and use `list.files()` to identify all `.R` files in the working directory:

Expand Down Expand Up @@ -185,7 +185,7 @@ Error: Can't upload file 'cleaning.R'.
* A file with the same name already exists at the destination.
* Use the `conflicts` argument to avoid this error in the future.
```

As the error indicates, we need to use the `conflicts` argument to instruct `osf_upload()` how to handle the conflict. In this case, we want to overwrite the original copy with our new version:

```{r, eval=FALSE}
Expand All @@ -196,7 +196,7 @@ Learn more about file versioning on OSF [here][osf-versioning].

### Sharing

Remember, new OFS projects are *always* private by default. You can change this by opening the project's settings page on OSF and making it public. See the following guides more information about OSF permissions and how to optionally generate a DOI so other can cite your project.
Remember, new OSF projects are *always* private by default. You can change this by opening the project's settings page on OSF and making it public. See the following guides more information about OSF permissions and how to optionally generate a DOI so other can cite your project.

* [Privacy Settings][osf-privacy]
* [Sharing Projects][osf-sharing]
Expand All @@ -211,7 +211,7 @@ We can download files from any public or private node that we have access to and
1. If we know where the file is located, but don't remember its GUID, you can use the `osf_ls_files` function to filter by filename within a specified node and then pipe the results to `osf_download()`.

```{r message=FALSE, eval=FALSE}
anes_project %>%
anes_project %>%
osf_ls_files(pattern = ) %>%
osf_download(conflicts = "overwrite")
```
Expand Down

0 comments on commit 80766a2

Please sign in to comment.