I am looking for input on how others organize their R code and output.
My current practice is to write code in blocks in a text file as such:
#=================================================
# 19 May 2011
date()
# Correlation analysis of variables in sed summary
load("/media/working/working_files/R_working/sed_OM_survey.RData")
# correlation between estimated surface and mean perc.OM in epi samples
cor.test(survey$mean.perc.OM[survey$Depth == "epi"],
survey$est.surf.OM[survey$Depth == "epi"]))
#==================================================
I then paste the output into another text file, usually with some annotation.
The problems with this method are:
- The code and the output are not explicitly linked other than by date.
- The code and output are organized chronologically and thus can be hard to search.
I have considered making one Sweave document with everything since I could then make a table of contents but this seems like it may be more hassle than the benefits it would provide.
Let me know of any effective routines you have for organizing your R code and output that would allow for efficient searching and editing the analysis.
sink()
orcapture.output()
might be your friends. Reporting utilities, like Hmisc, Sweave, or brew are worth to consider (your point 1). Versioning systems (rcs, svn, or git) might help with point 2. $\endgroup$sink()
andcapture.output()
. Thats great. $\endgroup$