[R] How to get the runtime as well as the result?

Dirk Eddelbuettel edd at debian.org
Fri Dec 11 02:03:13 CET 2009


On 10 December 2009 at 18:12, Peng Yu wrote:
| If I use system.time() to measure the runtime of an expression, I will
| not get the result. Is there a way to measure the runtime and get the
| result as well?

Use an assignment inside system.time(): 

    R> system.time( m <- max(rnorm(1e6)) )
       user  system elapsed 
      0.328   0.008   0.340 
    R> m
    [1] 4.993
    R> 

Dirk

-- 
Three out of two people have difficulties with fractions.




More information about the R-help mailing list