[R] turning R expressions into functions?

Dirk Eddelbuettel edd at debian.org
Sat Jun 30 20:28:13 CEST 2012


On 30 June 2012 at 11:39, Greg Snow wrote:
| Look at the replicate function, it takes an expression (does not need
| a function) and runs that expression the specified number of times.
| Will that accomplish what you want without needing to worry about
| substitute, quote, eval, etc.?

And also look at the existing benchmark packages 'rbenchmark' and
'microbenchmark':

   R> library(microbenchmark)
   R> x <- 5; microbenchmark( 1/x, x^-1 )
   Unit: nanoseconds
     expr min    lq median    uq  max
   1  1/x 296 322.5    341 364.0 6298
   2 x^-1 516 548.5    570 591.5 5422
   R> 

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com



More information about the R-help mailing list