Skip to Main Content

Course & Subject Guides

Data Sharing @ Pitt

Learn about the principles and how-to of sharing academic research data.

Including and documenting computer code

If you write code in a language such as Python, R, or MATLAB to collect, process, and/or analyze your data, then including the code with your shared data will help others to further understand your application of methods to the research question. Including your code is akin to “showing your work” on a math problem, in terms of making your research argument.

Some researchers worry that their code isn’t sufficiently “pretty,” perfect, or professional. However, what is important is that code is readable and gets the job done. (If you are concerned about readability, there are practices to improve it.) In terms of programming training and skill, the peers reviewing your code are likely to be in a similar situation to you.

For a reader to interpret code clearly, sometimes additional documentation is needed. An example of such documentation is comments inside the code which explain your design decisions or difficult-to-read bits of code. You might even consider working in notebooks, such as a Jupyter notebook or Quarto notebook, so that it’s easy to have English text alongside your Python or R code. Such notebooks make the document the primary product, with segments of code embedded in appropriate places.

Software development projects take code documentation even further, producing a manual of the functionality offered by the software package, often with code examples. Such proper documentation is needed for software meant to be consumed by other programmers, but not usually necessary for your own research code.

More resources for documenting computer code