To chime in here, I completely understand and have bought into the
thou-shalt-not-setwd(). But I have recently run into a situation where
I really wish there was some way to get knitr documents from elsewhere
within a directory structure. Here's the use case that really got me:
Working on my dissertation proposal I have a huge document with many
sub .rnws (that's fine, I just used \include{} in one master tex file
so each section was segregated enough). For each section I generally
have one r script that imports data, cleans it up, fits models (let's
call this setup.r), and then a bunch of individual r scripts for each
plot. When I went to make slides for my defense I wanted to use the
setup.r for each section in place so I didn't have to copy it along
with all of the data into the slides folder, just to use it in the
slides. Allowing for something like this would of course make the
slides a little bit harder to reproduce (they would depend on a
directory structure elsewhere), but it makes the entire project more
coherent (and possible reproducible as well?): the data and processing
scripts are all in a singel place, no need to diff each to see if
there are any differences between them. Additionally if the data is
nontrivially large, having multiple copies of it laying around could
be problematic.
I've run into something similar a few other times, and will admit this
particular use case might actually be an edge case. I'm not sure
there's a way to implement something like this without making it very
tempting for others to set paths like
/root/directories/that/will/be/deleted/foo.R
-Jon