Code Publishing Tutorial
Make your code and material available to others
This tutorial covers how to make your code and material available to others. It wraps up a series of tutorials which we recommend to go through in advance.
Tutorial Overview
This self-paced tutorial is intended to be worked through in order, one section after the other.
The tutorial is split into the following sections:
- Introduction motivates why you should publish your code and material.
- Project Setup prepares the project folder and the example manuscript used throughout.
- Sharing work of others: Copyright explains what you are allowed to share and under which conditions.
- Add Data and Data Dictionary adds the underlying data and documents it.
- Add Code adds the analysis code and makes the project reproducible.
- Choose a License picks an appropriate license for your content and code.
- Make a README writes the high-level documentation others need to reuse your project.
- Archive Your Project uploads the project to a repository and obtains a DOI.
We will start with creating a simple report which incorporates R code. Then, we will focus on what is required to publish your work:
- removing legal barriers: adding an appropriate license
- high-level documentation: creating a README file
- archival: uploading it to a repository
Prerequisite Tutorials
While the general principles taught in this tutorial apply to most researchers publishing code, we will focus on the programming language R and the publishing system Quarto. You may want to work through the following tutorials in advance:
- Introduction to version control with git and GitHub within RStudio: This tutorial explains how to set up a simple project with version control.
- Collaborative coding with GitHub and RStudio: Here you can learn how to collaborate with others on code projects using GitHub.
- Introduction to R: This is an introduction to the R programming language.
- Introduction to {renv}: Here you can learn how to manage the dependencies of an R project.
- Introduction to Quarto: Learn how to combine prose and code to make documents more reproducible.
- Introduction to Zotero: Get introduced to the reference management software Zotero.
- FAIR research data management: Learn how to make your data findable, accessible, interoperable, and reusable.
This tutorial assumes you have the following software installed:
Some things will be explained using the RStudio IDE, but you are free to use any IDE you like.
Quarto is a tool to render dynamic documents, but not the only one.
It is the successor of the R package rmarkdown and mostly backwards-compatible. rmarkdown continues to be supported, but the development of new features happens in Quarto. The main difference is that Quarto has first-class support for Python. In other words, Python users of Quarto do not need to have R installed.
While this tutorial focuses on Quarto, you can also create dynamic documents with the following tools:
Like this tutorial? Be sure to give the repository a star and follow us on GitHub!
If you have questions for the author of this tutorial, please take a look at the About page.