Yes, one way is to use commandArgs in the R script. So say your R script 
is as follows

  n   <- as.character(commandArgs()[3])
  fn  <- as.character(commandArgs()[4])

  mat <- matrix( rnorm( n*n ), nc=n )
  write.table( mat, filenames=fn, sep="\t", quote=FALSE )



Then you execute the commands from command line as

   R --no-save < script 100 out.txt


This will run the R commands and output them to "out.txt".



johan Faux wrote:
> I would like R CMD build to run some R code which does some stuff and save 
> the result as a file in /inst/docs folder. 
> Is there any way of doing this.
> 
> Thank you.
> Johan
> 
> 
> 
> 
>  
> ____________________________________________________________________________________
> We won't tell. Get more on shows you hate to love 
> 
> 
>       [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
> 
> 
>

______________________________________________
R-help@stat.math.ethz.ch 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