[R] How to get the runtime as well as the result?
Uwe Ligges
ligges at statistik.tu-dortmund.de
Fri Dec 11 11:00:42 CET 2009
Peng Yu wrote:
> On Thu, Dec 10, 2009 at 7:03 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>> 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>
>
> I see. In this case, I'll have to use '<-' rather than '='.
Thanks to point it out on the list. This is one of the reasons not to
use "=" as assignment operator at all: it is confusing.
Best,
Uwe Ligges
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list