Fetching the Data

Overview

Exercises: 20 min
Objectives
  • Retrieve our OSF data for use.

Accessing using OSFr in R

The first step is to sign into RStudio Cloud using your GitHub account.

Now you’ve created an RStudio Cloud account, you can clone the example OSFr project and use it to access your data.

To execute the project, we need to install the packages it depends on. Because the project uses the renv package to manage packages, we can install all the required packages by entering renv::restore() in the console and pressing Enter. It will take a little while for the packages to install. RStudio Cloud renv::restore() screenshot We then click on download_data.R to open that file. We’ll see that it opens as a pane in the top-left of the screen.

Downloading as .zip

You can also download your data directly from the OSF as a .zip (or as individual .csv files).

This is as simple as going to your project in the OSF, selecting the OSF Storage in the Files browser pane, and clicking the ‘Download as zip’ button. OSF download as .zip screenshot

Note:

At no point in these process did we tell the R script (or need to tell the web browser) who we were. The data are public, and can be accessed easily and immediately by anyone, including ourselves.

We can even write our analysis scripts to download the raw data each time, and thus track the raw data all the way to the figures and statistics we eventually produce for publication.

Key Points

  • The OSF API exposes the public data for us.

  • We access the data just like anyone else, without having to log in.