Sharing R code

Sharing software code produced during a research project has become standard procedure in many fields. In addition, publishers and funding agencies may require you to share your code as a provision for article publication or as part of your research grant. 

The Stanford Digital Repository (SDR) is an excellent option for sharing software code. The SDR is a Stanford University Libraries service that allows you to upload your files along with descriptive information into our preservation system. Your content will be assigned a persistent identifier, much like a DOI, and will be available at a persistent URL, or PURL. By doing this you will be making your content easily discoverable and citable by other researchers. You will also be fulfilling funding agency and publisher requirements for making code from your research available. Your content will be included in the Library catalog, which is crawled by Google, making your results available through a Google search.

R Plot

While you may be storing your code in a public repository like GitHub, the SDR is an excellent complement to that practice, because it allows you to preserve and share the exact version of the content used for a specific publication and to create reciprocal links between the publication and that version of the code.

In addition, you can power visualizations directly in R directly from data stored in the SDR. Check out an example in this blog post!

Below are some examples of R code that have been preserved in the Stanford Digital Repository.

Detailed Example

Researchers from Stanford and the University of Melbourne published a paper in Methods in Ecology and Evolution in 2015.

Screen shot of the title page of the article 

Within the article they include information indicating that the data and R code needed to reproduce the research can be found in the Stanford Digital Repository:

Screen shot of article mentioning PURL

The link to the PURL page takes users to the content in the Stanford Digital Repository:

screen shot of PURL page

They also include a reference to where the R package that implements their method can be found on GitHub:

Screen shot showing GitHub reference in article

The text above points to this GitHub Repository:

Screen shot of GitHub repository

accessibilityaccessprivsarrow-circle-rightaskus-chataskus-librarianbarsblogsclosecoffeecomputercomputersulcontactsconversationcopierelectricaloutleteventsexternal-linkfacebook-circlegroupstudyhoursindividualinterlibrarynewsnextoffcampusopenlateoutdoorpeoplepolicypreviousprinterprojectsquietreservesscannersearchstudysupportingtabletourstwitter-circleworking