Sweave, including R-Function files sourced from

I have a Rjob file in aR file that calls writen functions in bR file and snw c.snw file. I call c.snw through "R CMD c.snw".

I am looking for the opportunity to include aR through \ SweaveInput {aR} in c.snw, but the code of the functions called from aR should also be written in the tex file. This means that Sweave keeps track of all source () commands in the included main R file (here aR).

Can anyone suggest how to do this?

+3
source share
2 answers

I assume that in this case life with the package knitrwill be easier. You can read a.Ras a fragment label-aand write it to c.Rnw:

<<read-code>>=
read_chunk('a.R', labels = 'label-a')
@
<<label-a>>
@

c.Rnw library(knitr); knit('c.Rnw'), a.R ( label-a). knitr.

\SweaveInput{} R; Rnw.

+6

, , , source("b.R", echo = TRUE) a.R.

+2

All Articles