I found the mac console and tried the first solution as well. It works fine.

R -e "Sweave('test.Rnw')" --args PatientId=2

<<echo=F>>=
argString<-commandArgs(TRUE)
print(argString)
argList<-strsplit(argString,"=")[[1]]
print(argList)
assign(argList[1],as.numeric(argList[2]))
print(PatientId)
@

results in:

\begin{Schunk}
\begin{Soutput}
[1] "PatientId=2"
\end{Soutput}
\begin{Soutput}
[1] "PatientId" "2"
\end{Soutput}
\begin{Soutput}
[1] 2
\end{Soutput}
\end{Schunk}

Am 08.06.2012 um 11:00 schrieb Jessica Streicher:

> Well, i have my System not set up to run from command line, so i can't help 
> you there, but the scipt solution
> 
> id<-1
> Sweave('test.Rnw') #printing out the id
> 
> works fine for me. There were several other suggestions in the answers given 
> in the link.
> 
> Am 07.06.2012 um 09:30 schrieb Manish Gupta:
> 
>> Hi,
>> 
>> I followed the link u provided but getting some error.
>> 
>> R -e "Sweave('MyReport.Rnw')" --args PatientId=1
>> 
>> i am keeping commandArgs(TRUE) in my Rnw file. print(PatientId) // Error:
>> chunk 2 Error in print(PatientId) : object 'PatientId' not found Execution
>> halted
>> 
>> 
>> Any working example will help me a lot.
>> 
>> --
>> View this message in context: 
>> http://r.789695.n4.nabble.com/How-to-Read-command-line-parameters-in-Sweave-tp4632493p4632644.html
>> Sent from the R help mailing list archive at Nabble.com.
>> 
>> ______________________________________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> 
>       [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to