[R] run a script during R CMD build

Adaikalavan Ramasamy ramasamy at cancer.org.uk
Tue Mar 20 17:10:21 CET 2007


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 at 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.
> 
> 
>



More information about the R-help mailing list