On 03.11.2012 16:52, mrzung 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?
See ?Rprof on how to profile your code.
And,
apply(matrix,1,cumsum) command is too slow to some large matrix.
is there any function like rowCumSums ?
You had:
result1 <- apply(matrix,1,cumsum)
This is only "slow", if you have lots of rows. Now "think in matrices"
how to to that:
b <- sapply(1:ncol(matrix), function(i) c(rep(1, i), rep(0, ncol(matrix)-i)
result2 <- t(x %*% b)
This is roughly 10 times faster on a 1000000 x 10 matrix.
Check the results:
all.equal(result1, result2)
Uwe Ligges
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@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.
______________________________________________
R-help@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.