Is there any way to compile knitr subfiles separately? What I have in mind is something like the package subfiles for latex just in combination with R/knitr/Sweave? This would be great in case one has two exercises a first exercise with heavy computations and don't want to compile the entire exercise always while working and testing the second one.
Asked
Active
Viewed 108 times
2 Answers
0
The patchDVI
package does this for Sweave. I imagine it would be possible (maybe even easy) to modify it to do the same for knitr
.
For example, in Sweave, you define variables in a chunk like so:
<<>>=
.TexRoot <- "main.tex"
.SweaveFiles <- c("subfile1.Rnw", "subfile2.Rnw")
@
and after Sweave
is finished running that file, patchDVI
will check whether the files subfile1.Rnw
and subfile2.Rnw
also need to be run, then will run LaTeX on the main.tex
file once everything is up to date.

user2554330
- 37,248
- 4
- 43
- 90
0
You don't need to do anything difficult, just use the cache
options. Lots of details here, but it's probably as simple as specifying cache = T
in the chunk options of your first exercise.

Gregor Thomas
- 136,190
- 20
- 167
- 294