Skip to content
Prev 199923 / 398506 Next

Sweave() within a function: objects not found

On 11/11/2009 12:09 PM, Pfaff, Bernhard Dr. wrote:
The way you did it is close.  You can attach all the local variables by 
using

attach(environment())

though global variables will take precedence, because attach puts the 
environment 2nd in the search list.  And you'd better remember to detach 
them.

I'd say it's better to make Sweave files self-contained, so that you can 
run R CMD Sweave outside of R, and get the right results.  But if you 
really want to do this, then you can write your own Sweave driver and 
replace the default  RweaveEvalWithOpt  with a function that looks 
elsewhere for variables.

Duncan Murdoch