Documenting your work- Statistical Analysis (RDM continued)

How many of you document your statistical analysis code?  SAS and R users, do you add comments in your programs?  Or do you fly by the seat of your pants, write, modify code, and know that you’ll remember what you did at a later time?  I know we don’t have the time to add all this information in our code, but I cannot stress enough how IMPORTANT it is to do something!  I’ll use the same story as I did a few posts ago – and be honest!  Will you 100% remember WHY you adjusted that weight variable?  HOW you adjusted that weight variable?  WHY you dropped that observation or the other?   If you’re a paper person like myself – you may have written it down in your lab or notebook.  Fabulous!  BUT!  What happens to your notes when you archive your data and associated statistical programs?

Many if not all of the statistical programs that you are using have the ability to add comments among your code.  This is the easiest way to start documenting your statistical analysis.  When you archive your data, you will also archive your statistical analysis programs (.sas and .r are text files), so future users of your data will understand how your data was created.  Yes, there are other options to capture your documentation, one of these is Markdown.  Imagine writing your SAS or R code, adding documentation explaining what you do as you work through the code AND adding documentation to your output – all at the same time!

If you’re curious how Markdown works for both R and SAS, review this tutorial “Saving your code and making your research REPRODUCIBLE”. A more recent workshop demonstrating how to use R Markdown for R processes can be found at the Agri-food Research Data Workshop Series: Workshop 6: Documenting your Data and Processes with R Markdown .

Enjoy!  And remember if you have any questions or comments  – please let us know at adc@uoguelph.ca

Michelle