rOpenSci, Figshare and knitr.

This is a tutorial of how you can create reproducible documents using knitr and pandoc, and seamlessly upload them to figshare attaching a citable DOI to them. This document will walk you through the process of creating a document in knitr and uploading a compiled PDF to Figshare. I make the following assumptions about your knowledge:

The goal of this document is to demonstrate how one could carry out a project using tools from rOpenSci, knitr, and share the results on figshare in one continuous workflow. To do this I'll be using a tutorial from one of our packages, treebase, which allows you to download trees from TreebaseWEB

First I'll turn the cache on.

opts_chunk$set(cache=TRUE, autodep=TRUE)
dep_auto()

Then you'll want to download some data, and maybe make a plot, and say some things about how great your plot is.

library(treebase)
tree <- search_treebase("Derryberry", "author")[[1]] 
#plotting only part of the tree because it's so large
plot.phylo(tree,y.lim=c(0,20))

Once you've made all your plots, and said all you want to say it's time to convert your document, and then create a new article using fs_new_article()

library(knitr)
library(rfigshare)
options(FigshareKey = "XXXXXXXX")
options(FigsharePrivateKey = "XXXXXXXX")
options(FigshareToken = "XXXXXXXX")
options(FigsharePrivateToken = "XXXXXXXX")

#knit document to pandoc markdown
knit("rfigtutorial.Rmd")
#convert to pdf
system("pandoc -S rfigtutorial.md -o rfigtutorial.pdf")

id <- fs_new_article(title="An rfigshare tutorial", 
                      description="How to create a document in knitr and 
                      upload it to figshare.com", 

                      type="paper", 
                      authors=c("Edmund Hart"), 
                      tags=c("ecology", "openscience"), 
                      categories="Ecology", 
                      links="http://emhart.github.com", 
                      files="rfigtutorial.pdf",
                      visibility="draft")

The main advantage of this approach is that manuscripts can be worked on from within the R environment and then seemlessly uploaded to figshare. Also it's best practice to store your key values in your .Rprofile so I would reccomend file Be sure to run fs_make_public(id) when you're ready to make your article public.



Try the rfigshare package in your browser

Any scripts or data that you put into this service are public.

rfigshare documentation built on May 10, 2022, 1:05 a.m.