[R] to print system.time always
Uwe Ligges
ligges at statistik.tu-dortmund.de
Sat Nov 3 19:54:32 CET 2012
On 03.11.2012 19:42, jim holtman wrote:
> Here is a faster solution to your 'apply'; use 'sapply' instead:
>
>> str(x)
> num [1:1000000, 1:30] 0.0346 0.4551 0.66 0.8528 0.5494 ...
>
>> system.time(y <- apply(x, 1, cumsum))
> user system elapsed
> 13.24 0.61 14.02
>> system.time(ys <- sapply(1:col, function(a) cumsum(x[,a])))
> user system elapsed
> 1.40 0.14 1.59
Which solves another problem (cumsum of cols rather than rows). Applying
it on rows won't be much faster.
Uwe Ligges
>
> On Sat, Nov 3, 2012 at 11:52 AM, mrzung <mrzung46 at gmail.com> wrote:
>> Hi all;
>>
>> I want to print system.time whenever I execute any command.
>>
>> It takes too much time to type "system.time()" function to all command.
>>
>> is there any solution on it?
>>
>> And,
>>
>> apply(matrix,1,cumsum) command is too slow to some large matrix.
>>
>> is there any function like rowCumSums ?
>>
>> thank u!
>>
>>
>>
>> --
>> View this message in context: http://r.789695.n4.nabble.com/to-print-system-time-always-tp4648314.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> 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