• Stars
    star
    136
  • Rank 257,993 (Top 6 %)
  • Language
    R
  • License
    Other
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

R interface to the Open Science Framework (OSF)

osfr

CRAN status R-CMD-check Coverage status JOSS DOI

Overview

osfr provides a suite of functions for interacting with the Open Science Framework (OSF).

What is OSF?

OSF is a free and open source project management repository designed to support researchers across their entire project lifecycle. The service includes unlimited cloud storage and file version history, providing a centralized location for all your research materials that can be kept private, shared with select collaborators, or made publicly available with citable DOIs.

Installation

You can install the current release of osfr from CRAN (recommended):

install.packages("osfr")

Or the development version from GitHub with the remotes package:

# install.packages("remotes")
remotes::install_github("ropensci/osfr")

Usage Examples

Note: You need to setup an OSF personal access token (PAT) to use osfr to manage projects or upload files.

Accessing Open Research Materials

Many researchers use OSF to archive and share their work. You can use osfr to explore publicly accessible projects and download the associated files—all you need to get started is the project’s URL or GUID (global unique identifier).

Every user, project, component, and file on OSF is assigned a GUID that is embedded in the corresponding entity’s URL. For example, you can access the main OSF project for the Cancer Reproducibility Project at https://osf.io/e81xl/. The GUID for this project is e81xl.

We can then use osfr to retrieve this project and load it into R by providing the GUID:

library(osfr)

cr_project <- osf_retrieve_node("e81xl")
cr_project
#> # A tibble: 1 × 3
#>   name                                    id    meta            
#>   <chr>                                   <chr> <list>          
#> 1 Reproducibility Project: Cancer Biology e81xl <named list [3]>

This returns an osf_tbl object with a single row representing the retrieved project. Let’s list the files that have been uploaded to this project.

osf_ls_files(cr_project)
#> # A tibble: 4 × 3
#>   name                                        id                    meta        
#>   <chr>                                       <chr>                 <list>      
#> 1 papers_and_keywords.xlsx                    553e671b8c5e4a219919… <named list>
#> 2 Full_dataset_of_papers_formatted.xls        553e671b8c5e4a219919… <named list>
#> 3 METHOD_to_select_papers.txt                 553e671b8c5e4a219919… <named list>
#> 4 Adjustment of 50 studies to 37 studies.docx 565602398c5e4a3877d7… <named list>

This returns another osf_tbl with 1 row for each of the files and directories in the project. We can examine any of these files directly on OSF with osf_open(), which opens the corresponding file’s view in your default browser.

This project contains 2 components: Replication Studies and Data collection and publishing guidelines. We can list these components with osfr using osf_ls_nodes().

osf_ls_nodes(cr_project)
#> # A tibble: 5 × 3
#>   name                                                        id    meta        
#>   <chr>                                                       <chr> <list>      
#> 1 Meta-analysis paper figures and tables                      squy7 <named list>
#> 2 Replication Data from the Reproducibility Project: Cancer … e5nvr <named list>
#> 3 Process paper figures and reported statistics               35ut8 <named list>
#> 4 Replication Studies                                         p7ayb <named list>
#> 5 Data collection and publishing guidelines                   a5imq <named list>

osfr is compatible with the pipe operator and dplyr, providing a powerful set of tools for working with osf_tbls. Here, we’re listing the sub-components nested within the Replication Studies component, filtering for a specific study (Study 19) and then listing the files uploaded to that study’s component.

library(dplyr)

cr_project %>%
  osf_ls_nodes() %>%
  filter(name == "Replication Studies") %>%
  osf_ls_nodes(pattern = "Study 19") %>%
  osf_ls_files()
#> # A tibble: 6 × 3
#>   name                                      id                      meta        
#>   <chr>                                     <chr>                   <list>      
#> 1 Replication_Study_19.Rmd                  578e2b23594d9001f48164… <named list>
#> 2 Study_19_Correction_Letter.docx           5a56569125719b000ff28b… <named list>
#> 3 Replication_Study_19.docx                 57c9e8ed594d9001e7a240… <named list>
#> 4 Response_letter_Replication_Study_19.docx 58755747b83f6901ff066a… <named list>
#> 5 Replication_Study_19_track_changes.docx   581a27b76c613b02233228… <named list>
#> 6 Replication_Study_19_track_changes_2.docx 58714d46594d9001f801f4… <named list>

We could continue this pattern of exploration and even download local copies of project files using osf_download(). Or, if you come across a publication that directly references a file’s OSF URL, you could quickly download it to your project directory by providing the URL or simply the GUID:

osf_retrieve_file("https://osf.io/btgx3/") %>%
  osf_download()
#> # A tibble: 1 × 4
#>   name                  id    local_path              meta            
#>   <chr>                 <chr> <chr>                   <list>          
#> 1 Study_19_Figure_1.pdf btgx3 ./Study_19_Figure_1.pdf <named list [3]>

Managing Projects

You can use osfr to create projects, add sub-components or directories, and upload files. See Getting Started to learn more about building projects with osfr, but here is a quick example in which we:

  1. Create a new project called Motor Trend Car Road Tests
  2. Create a sub-component called Car Data
  3. Create a directory named rawdata
  4. Upload a file (mtcars.csv) to the new directory
  5. Open the uploaded file on OSF
# create an external data file
write.csv(mtcars, "mtcars.csv")

osf_create_project(title = "Motor Trend Car Road Tests") %>%
  osf_create_component("Car Data") %>%
  osf_mkdir("rawdata") %>%
  osf_upload("mtcars.csv") %>%
  osf_open()

Screenshot of the uploaded file on OSF

Details on osf_tbls

There are 3 main types of OSF entities that osfr can work with:

  1. nodes: both projects and components (i.e., sub-projects) are referred to as nodes
  2. files: this includes both files and folders stored on OSF
  3. users: individuals with OSF accounts

osfr represents these entities within osf_tbls—specialized data frames built on the tibble class that provide useful information about the entities like their name and unique id for users, and API data in the meta column that’s necessary for osfr’s internal functions. Otherwise, they’re just data.frames and can be manipulated using standard functions from base R or dplyr.

Acknowledgments

OSF is developed by the Center for Open Science in Charlottesville, VA.

The original version of osfr was developed by Chris Chartgerink and further developed by Brian Richards and Ryan Hafen. The current version was developed by Aaron Wolen and is heavily inspired by Jennifer Bryan and Lucy D’Agostino McGowan’s excellent googledrive package. Seriously, we borrowed a lot of great ideas from them. Other important resources include http testing by Scott Chamberlain and R Packages by Hadley Wickham. Development was also greatly facilitated by OSF’s excellent API documentation.

Big thanks to Rusty Speidel for designing our logo and Tim Errington for his feedback during development.

Contributing

Check out the Contributing Guidelines to get started with osfr development and note that by contributing to this project, you agree to abide by the terms outlined in the Contributor Code of Conduct.

ropensci_footer

More Repositories

1

drake

An R-focused pipeline toolkit for reproducibility and high-performance computing
R
1,329
star
2

skimr

A frictionless, pipeable approach to dealing with summary statistics
HTML
1,095
star
3

targets

Function-oriented Make-like declarative workflows for R
R
854
star
4

rtweet

🐦 R client for interacting with Twitter's [stream and REST] APIs
R
785
star
5

tabulizer

Bindings for Tabula PDF Table Extractor Library
R
518
star
6

pdftools

Text Extraction, Rendering and Converting of PDF Documents
C++
489
star
7

magick

Magic, madness, heaven, sin
R
440
star
8

visdat

Preliminary Exploratory Visualisation of Data
R
439
star
9

stplanr

Sustainable transport planning with R
R
412
star
10

RSelenium

An R client for Selenium Remote WebDriver
R
332
star
11

rnoaa

R interface to many NOAA data APIs
R
320
star
12

osmdata

R package for downloading OpenStreetMap data
C++
307
star
13

charlatan

Create fake data in R
R
283
star
14

software-review

rOpenSci Software Peer Review.
R
279
star
15

iheatmapr

Complex, interactive heatmaps in R
R
259
star
16

taxize

A taxonomic toolbelt for R
R
250
star
17

rrrpkg

Use of an R package to facilitate reproducible research
248
star
18

elastic

R client for the Elasticsearch HTTP API
R
244
star
19

tesseract

Bindings to Tesseract OCR engine for R
R
236
star
20

qualtRics

Download ⬇️ Qualtrics survey data directly into R!
R
213
star
21

git2r

R bindings to the libgit2 library
R
213
star
22

biomartr

Genomic Data Retrieval with R
R
203
star
23

writexl

Portable, light-weight data frame to xlsx exporter for R
C
202
star
24

rnaturalearth

An R package to hold and facilitate interaction with natural earth map data 🌍
R
191
star
25

googleLanguageR

R client for the Google Translation API, Google Cloud Natural Language API and Google Cloud Speech API
HTML
190
star
26

textreuse

Detect text reuse and document similarity
R
188
star
27

tokenizers

Fast, Consistent Tokenization of Natural Language Text
R
179
star
28

rentrez

talk with NCBI entrez using R
R
178
star
29

piggyback

📦 for using large(r) data files on GitHub
R
172
star
30

rcrossref

R client for various CrossRef APIs
R
164
star
31

osmextract

Download and import OpenStreetMap data from Geofabrik and other providers
R
158
star
32

dataspice

🌶️ Create lightweight schema.org descriptions of your datasets
R
155
star
33

tic

Tasks Integrating Continuously: CI-Agnostic Workflow Definitions
R
153
star
34

webchem

Chemical Information from the Web
R
149
star
35

geojsonio

Convert many data formats to & from GeoJSON & TopoJSON
R
148
star
36

MODIStsp

An "R" package for automatic download and preprocessing of MODIS Land Products Time Series
R
147
star
37

rgbif

Interface to the Global Biodiversity Information Facility API
R
146
star
38

tsbox

tsbox: Class-Agnostic Time Series in R
R
146
star
39

DataPackageR

An R package to enable reproducible data processing, packaging and sharing.
R
145
star
40

ghql

GraphQL R client
R
141
star
41

dev_guide

rOpenSci Packages: Development, Maintenance, and Peer Review
R
141
star
42

jqr

R interface to jq
R
139
star
43

osmplotr

Data visualisation using OpenStreetMap objects
R
130
star
44

opencv

R bindings for OpenCV
C++
130
star
45

ssh

Native SSH client in R based on libssh
C
126
star
46

tarchetypes

Archetypes for targets and pipelines
R
116
star
47

RefManageR

R package RefManageR
R
112
star
48

spocc

Species occurrence data toolkit for R
R
109
star
49

ezknitr

Avoid the typical working directory pain when using 'knitr'
R
107
star
50

hunspell

High-Performance Stemmer, Tokenizer, and Spell Checker for R
C++
106
star
51

crul

R6 based http client for R (made for developers)
R
101
star
52

gistr

Interact with GitHub gists from R
R
101
star
53

spelling

Tools for Spell Checking in R
R
101
star
54

rfishbase

R interface to the fishbase.org database
R
100
star
55

weathercan

R package for downloading weather data from Environment and Climate Change Canada
R
99
star
56

git2rdata

An R package for storing and retrieving data.frames in git repositories.
R
98
star
57

gutenbergr

Search and download public domain texts from Project Gutenberg
R
97
star
58

bib2df

Parse a BibTeX file to a tibble
R
97
star
59

ckanr

R client for the CKAN API
R
97
star
60

rsvg

SVG renderer for R based on librsvg2
C
95
star
61

UCSCXenaTools

📦 An R package for accessing genomics data from UCSC Xena platform, from cancer multi-omics to single-cell RNA-seq https://cran.r-project.org/web/packages/UCSCXenaTools/
R
95
star
62

EML

Ecological Metadata Language interface for R: synthesis and integration of heterogenous data
R
94
star
63

nasapower

API Client for NASA POWER Global Meteorology, Surface Solar Energy and Climatology in R
R
93
star
64

cyphr

:shipit: Humane encryption
R
91
star
65

FedData

Functions to Automate Downloading Geospatial Data Available from Several Federated Data Sources
R
91
star
66

av

Working with Video in R
C
88
star
67

mapscanner

R package to print maps, draw on them, and scan them back in
R
87
star
68

opencage

🌐 R package for the OpenCage API -- both forward and reverse geocoding 🌐
R
86
star
69

tidync

NetCDF exploration and data extraction
R
85
star
70

GSODR

API Client for Global Surface Summary of the Day ('GSOD') Weather Data Client in R
R
84
star
71

rzmq

R package for ZMQ
C++
82
star
72

gittargets

Data version control for reproducible analysis pipelines in R with {targets}.
R
80
star
73

openalexR

Getting bibliographic records from OpenAlex
R
80
star
74

bikedata

🚲 Extract data from public hire bicycle systems
R
79
star
75

historydata

Datasets for Historians
R
78
star
76

dittodb

dittodb: A Test Environment for DB Queries in R
R
78
star
77

arkdb

Archive and unarchive databases as flat text files
R
78
star
78

fingertipsR

R package to interact with Public Health England’s Fingertips data tool
R
78
star
79

vcr

Record HTTP calls and replay them
R
77
star
80

rebird

Wrapper to the eBird API
R
77
star
81

smapr

An R package for acquisition and processing of NASA SMAP data
R
77
star
82

nodbi

Document DBI connector for R
R
75
star
83

CoordinateCleaner

Automated flagging of common spatial and temporal errors in biological and palaeontological collection data, for the use in conservation, ecology and palaeontology.
HTML
74
star
84

opentripplanner

An R package to set up and use OpenTripPlanner (OTP) as a local or remote multimodal trip planner.
R
73
star
85

nlrx

nlrx NetLogo R
R
71
star
86

rb3

A bunch of downloaders and parsers for data delivered from B3
R
69
star
87

tidyhydat

An R package to import Water Survey of Canada hydrometric data and make it tidy
R
69
star
88

robotstxt

robots.txt file parsing and checking for R
R
68
star
89

slopes

Package to calculate slopes of roads, rivers and trajectories
R
65
star
90

tradestatistics

R package to access Open Trade Statistics API
R
65
star
91

terrainr

Get DEMs and orthoimagery from the USGS National Map, georeference your images and merge rasters, and visualize with Unity 3D
R
64
star
92

unconf17

Website for 2017 rOpenSci Unconf
JavaScript
64
star
93

NLMR

📦 R package to simulate neutral landscape models 🏔
R
63
star
94

roadoi

Use Unpaywall with R
R
63
star
95

parzer

Parse geographic coordinates
R
63
star
96

tiler

Generate geographic and non-geographic map tiles from R
R
63
star
97

rWBclimate

R interface for the World Bank climate data
R
62
star
98

codemetar

an R package for generating and working with codemeta
R
62
star
99

comtradr

Functions for Interacting with the UN Comtrade API
R
60
star
100

aRxiv

Programmatic interface to the Arxiv API
R
58
star