Comments on Comments in R

When you are busy with a lengthy project, like writing a paper, you create many objects along the way. Every time you log into the project, you need to remember what is what. In the past, each new working session I used to rerun the script anew and follow what each line is doing until I get back the objects I need and continue working. Apart from helping you remember what you are doing, it is very useful for reproducibility, at least given your data, in the sense that you are sure nothing is overrun using the console and it is all there. Those days are over.

Advanced statistical procedures nowadays are:

(1) Heavy, time and CPU hungry.
(2) Worth the trouble.

You will not wait 8 hours every time you re-connect with your previous session. A solution is to save the objects and to load them into the workspace each session. But then, how do you remind yourself what is what? To make it easier to return to work after referee reports come back (which can take a while..), you can attach comments along the way:

An extended version is to write the actual code that generated the object along with some more things you think you may forget into a COMMENTS.txt file. Once done, attach the COMMENTS.txt file as a comment like so:

comment(x) <- readLines("path/COMMENTS.txt", warn = F) This allows more extensive description and code attachment without cluttering the actual script.

Leave a Reply

Your email address will not be published. Required fields are marked *