By input files do you mean
1) R scripts from which you read chunks or
2) data files which you are reading into R
I will describe my current work flow
My current work flow has my working directory set and I DO NOT change this.
I have my .rnw (or .rmd (markdown not sweave / latex) files in a sub directory
'code/'
and my data in another subdirectory
'data/'
To knit a document I manually copy the file from code/my-file.rnw to the working directory
using
file.copy('code/my-file.rnw','my-file.rnw')
output <- knit2pdf('my-file.rnw')
all the paths in this document are relative to the working directory (not the code subdirectory)
If you are using Rstudio set the default working directory to your current working directory (or use a project based in that working directory)
Michael
Hi,
Just switched from Sweave to Knitr so this is probably basic.
I'm running a knitted document from a different directory than where the input files for my R chunks are.
As it is now, I have to provide setwd() in each chunk individually for it to find the files (although it's the same wd throughout the document).
I tried:
1. switching to the wd in RStudio before running the code
2. using setwd() in the same chunk as the knitr options
3. using dependson="chunk-where-setwd()-is-set"
but none worked
Tips are welcomed.
Thanks
Roey