Hello,

I wrote a function create_report that calls the function Sweave.
create_report shall be used to create a pdf-report about an lm-Object which
is passed as an argument to create_report.

I try to use an object sel_model, that is created within the function
environment of create_report and later on used within the first code chunk
of the file report_template.rnw.

When I use following code I get an error message that the object sel_model
could not been found. How can I achieve to use objects within code-chunks
that are not globally available, but only within my function call of
create_report? Is it only possible to use globally available objects within
a code chunk?

 

create_report<-function(model_lst){

#define parameters

sel_model<-model_lst

Sweave('report_template.rnw')

tools::texi2dvi("report_template.tex", pdf=TRUE)

}

 

create_report(p3)

 

 

this is the file report_template.rnw

 

\documentclass[a4paper]{article}

\begin{document}

 

<<echo=FALSE>>=

summary(sel_model)

@

\begin{center}

<<fig=TRUE,echo=FALSE>>=

plot_fx(sel_model)

@

\end{center}

 

\end{document}

 


	[[alternative HTML version deleted]]

