I am creating reports using R, RStudio, knitr
, and packrat
. I have a project folder structure similar to below:
project_folder/
- packrat/
- .Rprofile
- analaysis_folder/
- library.R
- child.rnw
- data_folder/
- knitr_rnw_location/
- file.rnw
- .Rprofile
And have set up the .Rprofile
with the appropriate lines in the main project_folder
and the subdirectory of the .rnw
file, according to the recommendations given in RStudio's Limitations and Caveats page.
When I run packrat::init()
at the project_folder
level, the packrat
folder is set up. Then when I open the file.rnw
the packrat
library is all set up.
However, when I execute packrat::snapshot()
it gives errors
Unable to tangle file knitr_rnw_location/file.rnw; cannot parse depndencies
and fails. Is there a way to tell packrat
to ignore my .rnw
files? All library()
are called from separate .R
scripts and are source()
through the .rnw
files. It also searches any variables declared in the knitr
chunks and gives the error
Error in eval(x, envir = envir): object 'my_variable_name' not found
In the end, it does state
Snapshot written to "~/project_folder/packrat/packrat.lock"
So I can only assume that packrat::snapshot()
was successful. Has anyone else run into the same issue when working with knitr
and packrat
?
Much appreciated,