Skip to Main Content

Learning and Using R at Stanford

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.

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.

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

Detailed Example

Code and data supplement for "Bias Correction in Species Distribution Models: Pooling Survey and Collection Data for Multiple Species"

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

screen shot of the title of paper 

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:

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

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

The text above points to this GitHub Repository:

Additional Examples

(View in Searchworks)

R programs and data sets that are supplementary material for PNAS article: Temporal and Spatial Variation of the Human Microbiota during Pregnancy.

Code Supplement to "Marine anoxia and delayed Earth system recovery after the end-Permian extinction"

Mathematical Model of Medicare Chronic Care Management Payments and Financial Returns to Primary Care Practices.

Arduino tide prediction libraries and tide height control system.

Code Supplement to "Oxygen isotope mass-balance constraints on Pliocene sea level and East Antarctic Ice Sheet stability"

Code Supplement to "Quantifying the isotopic 'continental effect'"