I am writing my dissertation and I have a question on how to present my results.

So I have used Rstudio to write the code with which I did some statistical analysis by using some tests. I have included all the results of the tests in a table which I have added in my dissertation.

Now, I am unsure if I need to add the code that I used as well and if I need to explain how to use it. I don't know, since my dissertation is not focused on the code, and I could have done it with SPSS. I am not really restricted on the method of doing the tests thus I don't know how much I should focus on the code itself. So yeah, Rstudio is just a tool, is not a requirement.

Thank you in advance!

  • 2
    If the code wasn't a focus, you can also always include it in an appendix.
    – JoshuaZ
    Aug 7, 2021 at 16:05
  • 1
    This seems like a question for your advisor.
    – Buffy
    Aug 7, 2021 at 16:28
  • I try to conduct him but he doesnt respond fast, I have a deadline near by and the other person that advises me, isnt sure as well
    – makala
    Aug 7, 2021 at 16:42
  • Do you think, i should explain the code, or just adding comments is enough?
    – makala
    Aug 7, 2021 at 16:43

3 Answers 3


How much, if any, explanation of the code you include in your dissertation is a question best answered by your advisor.

However, it is critical for reproducibility that if numerical simulations are done that the source code used for them is made available. With the internet and sites like github, bitbucket, etc. it is trivially simple to share code and enable others to replicate numerical experiments and simulations.

If the numerical methods themselves aren't the subject of research, i.e. you just used some standard methods in R for some analysis, a single line similar to "statistical analysis was performed in R using the code found at <insert your github>." Or, if there isn't much code, it can likely be inserted directly in an appendix.

Regardless of where the code is shared, it's important to note which versions/packages/dependencies were used as well. Ideally the code should be clear and well documented, but an inordinate amount of time can be spent "explaining how to use it." If possible also store in repository or link any datasets used.

Only saying something along the lines of "statistical analysis was done in R", or "a custom implicit-explicit numerical method was used to solve the equations" really is terrible for reproducibility and should be considered bad form. As an analogy take the beginning of an experimental section of a recent chemistry paper. (This one FYI)

All commercially available reagents and solvents used in this study were purchased from TCI, Fisher or Sigma-Aldrich and used without further purification. Flash column chromatography was performed using 40−63μm silica gel (SiliaFlash F60 from Silicycle). Preparative thin-layer chromatography was performed on silica gel 60 Å F254 plates (20×20 cm, 1000μm, SiliaPlate from Silicycle) and visualized with UV light (254/360 nm)

The poor examples of numerical reproducibility would be like instead of all that thorough explaining of the materials and methods the authors just said, "We used store bought products, used chromatography with silica gel, and looked at it with light."


If possible, include it.

As I infer from your question, the wrote new code which wasn't available to you from a different venue (e.g., as a package from CRAN) which you may cite by address and version used, and it was one of your essential tools to process the data. The inclusion of your code written into your thesis allows the members of the thesis jury to replicate what you have done (perhaps some will not pick up the code at all, others might be highly interested to check the methodologies applied). Some of the printed theses I have seen included both a briefly commented presentation of the code (e.g. via LaTeX usepackage listings, equally supporting R), as well as the relevant code copied to a CD; today, the electronic repositories by universities and their libraries may accept both the .pdf version of your thesis and this supplementary material (executable code and data within a .zip archive).

Sharing your tools used with future members of your group allows them to continue work along the direction of research, to include your methodologies in other programs. This may lead to publications with you as a co-author. Equally (if not yet part of the SI of your research publications), this eases a lot the replication of work you contributed by others equally known as reproducible research (e.g., see the first part of this presentation) and is part of the FAIR principles. (Since you opted for a programmatic approach, quite some issues seen with spreadsheets [an incomplete listing] already are out of the way.)

With agreement from your supervisor/your university, you might consider the publication of your code on platforms like CRAN (example), GitHub (example of a search for finance and R) with some additional effort. As method it may be suitable for a separate article of a non-specialized venue like JOSS (example), or one with focus on your specialty, too.


Based on my experience, you can generate a report with figures embedded for your dissertation using r Markdown and you could deposit your code and source files on GitHub. For a pub, you may want to add this info in a supplementary file. Definitely get approval from your PI before releasing info to the public on GitHub. :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .