Build Status

rfigshare

An R interface to FigShare

Getting Started

Figshare is an online digital repository where researchers can preserve and share their research outputs, including figures, datasets, images, and videos. It is free to upload content and free to access, in adherence to the principle of open data.

Key Features: - Showcase your institution's research with a customizable portal of all public research outputs using the reporting and statistics feature. - Have full control of your institution's research outputs with private storage, public storage and collaborative spaces with the data management feature. - Filter your institution's research by department, category or file type, and rank content by most viewed, downloaded or shared with the data dissemination feauture. - Manage the curation of files to be made public, control quotas, and administer rights with the user group administration feature.

Using rfigshare

library("rfigshare")
# This loads the rOpenSci figshare sandbox credentials, so that the example 
# can run automatically during check and install.  Unlike normal figshare accounts,
# data loaded to this testing sandbox is periodically purged.  
fs_auth(token = "xdBjcKOiunwjiovwkfTF2QjGhROeLMw0y0nSCSgvg3YQxdBjcKOiunwjiovwkfTF2Q", token_secret = "4mdM3pfekNGO16X4hsvZdg")

The first time you use an rfigshare function, it will ask you to authenticate online. Just log in and click okay to authenticate rfigshare. R will allow you to cache your login credentials so that you won't be asked to authenticate again (even between R sessions), as long as you are using the same working directory in future.

Try a search for an author:

fs_author_search("Boettiger")

Try creating your own content:

id <- fs_create("Test title", "description of test")

This creates an article with the essential metadata information. We can now upload the dataset to this newly created figshare object using fs_upload. For the purposes of this example, we'll just upload one of R's built-in datasets:

data(mtcars)
write.csv(mtcars, "mtcars.csv")
fs_upload(id, "mtcars.csv")

Note that we must pass the id number of our the newly created figshare object as the first argument. Similar functions let us add additional authors, tags, categories, and links, e.g.

fs_add_tags(id, "demo")

Minimal metadata includes title, description, type, and at least one tag and one category. We can add categories using either the category id or the name of the category, but it must be one of the preset categories available. We can ask the API for a list of all the categories:

fs_category_list()

And we can add the category or categories we like,

fs_add_categories(id, c("Education", "Software Engineering"))

The file we have created remains saved as a draft until we publish it, either publicly or privately. Note that once a file is declared public, it cannot be made private or deleted. Let's release this dataset privately:

fs_make_private(id)

We can now share the dataset with collaborators by way of the private url.

The quick and easy way

The rfigshare package will let you create a new figshare article with additional authors, tags, categories, etc in a single command usnig the fs_new_article function. The essential metadata title, description and type are required, but any other information we omit at this stage can be added later. If we set visibility to private or public, the article is published on figshare immediately.

data(mtcars)
write.csv(mtcars,"mtcars.csv")
id <- fs_new_article(title="A Test of rfigshare", 
                     description="This is a test", 
                     type="dataset", 
                     authors=c("Karthik Ram", "Scott Chamberlain"), 
                     tags=c("ecology", "openscience"), 
                     categories="Ecology", 
                     links="http://ropensci.org", 
                     files="mtcars.csv",
                     visibility="private")
unlink("mtcars.csv") # clean up

Examining Data on Figshare

We can view all available metadata of a figshare object.

fs_details(id)

You can see all of the files you have (Currently only up to 10):

mine <- fs_browse()
mine[1:2]

Note that we can easily grab the ids with the wrapper function fs_ids:

fs_ids(mine)

We can delete unwanted files that are not public with fs_delete:

fs_delete(id)

To cite package rfigshare in publications use:

citation("rfigshare")

ropensci.org logo\



ropensci/rfigshare documentation built on May 18, 2022, 6:34 p.m.