mara
April 7, 2018, 2:19pm
2
You might find this thread relevant.
Often, when I create an RMarkdown report, I like to integrate my code chunks with my write-up. For example, I would include the code chunks for pulling and cleaning data in with the section describing my dataset. I would include chunks related to running and checking a model in the section that describes that model, etc. This makes it easy for me to move from writing code in a notebook like fashion, to writing up a more polished report. It also makes it easy to sort through my RMarkdown file to answer questions / make updates related to a specific aspect of the report.
However, things are not as easy when the order of my code does not match the order of my write-up. This is a particular pro…
I think perhaps that figure is a bit misleading (if interpreted literally) in terms of actual workflows. The scripts and chunks probably aren't being written or executed for the first time in article format. There's no need to put them in different directories if you use workflow tips, such as those described in Jenny's article and the latter thread below.
I wrote a blog post elaborating on recent provocative slides that discourage the use of setwd() and rm(list = ls()) at the top of R scripts.
The Twitter reaction was a bit shocking in volume and it's hard to discuss things there. So I've made this thread in case the conversation continues! Note: we've had a semi-related thread already: First line of every R script? .
3 Likes