When introduced to R, I learned how to use *apply whenever I could to avoid
for-loops and all. And, getting the habit, I think I somehow got the
mis-conception that it is a magic source, always an optimal way of coding in
R.
Thanks a lot for all of your helpful advice and comment!
Young
On Wed,
On Wed, Jan 5, 2011 at 10:49 PM, Young Cho young.s...@gmail.com wrote:
When introduced to R, I learned how to use *apply whenever I could to avoid
for-loops and all. And, getting the habit, I think I somehow got the
mis-conception that it is a magic source, always an optimal way of coding in
On 05.01.2011 22:49, Young Cho wrote:
When introduced to R, I learned how to use *apply whenever I could to avoid
for-loops and all. And, getting the habit, I think I somehow got the
mis-conception that it is a magic source, always an optimal way of coding in
R.
That is right, but your apply
Hi,
I am doing some simulations and found a bottle neck in my R script. I made
an example:
a = matrix(rnorm(500),100,5)
tt = Sys.time(); sum(a[,1]*a[,2]*a[,3]*a[,4]*a[,5]); Sys.time() - tt
[1] -1291.026
Time difference of 0.2354031 secs
tt = Sys.time(); sum(apply(a,1,prod));
On Jan 5, 2011, at 10:03 AM, Young Cho wrote:
Hi,
I am doing some simulations and found a bottle neck in my R script.
I made
an example:
a = matrix(rnorm(500),100,5)
tt = Sys.time(); sum(a[,1]*a[,2]*a[,3]*a[,4]*a[,5]); Sys.time() - tt
[1] -1291.026
Time difference of 0.2354031
On Wed, Jan 5, 2011 at 1:22 PM, David Winsemius dwinsem...@comcast.net wrote:
On Jan 5, 2011, at 10:03 AM, Young Cho wrote:
Hi,
I am doing some simulations and found a bottle neck in my R script. I made
an example:
a = matrix(rnorm(500),100,5)
tt = Sys.time();
On Jan 5, 2011, at 2:40 PM, Douglas Bates wrote:
On Wed, Jan 5, 2011 at 1:22 PM, David Winsemius dwinsem...@comcast.net
wrote:
On Jan 5, 2011, at 10:03 AM, Young Cho wrote:
Hi,
I am doing some simulations and found a bottle neck in my R
script. I made
an example:
a =
Hi,
I'm just starting out with R and came across R_inferno.pdf by Patrick Burns
just yesterday - I recommend it!
His description of how 'growing' objects (e.g. obj - c(obj,
additionalValue) eats up memory prompted me to rewrite a function (which
made such calls ~210 times) so that it used
Actually the issue is not the size of memory that is consumed, but that
memory allocation takes place and the object is copied in each iteration
of the bad loop you have given below. This is not required for the
second loop, where R can allocate the memory at once and does not need
to copy the
Hard to say. You might want to run a profile of each set of code and see
where it is spending its time. It looks like from the R code that they are
using vectorized operations and depending on how some of them are
implemented, they might be calling C code to do most of the work. With the
proper
Your choice of subject line alone shows some people that you missed some
small details from the posting guide. The ability to notice small details
may be important for you to demonstrate in future. Any answer in this
thread is unlikely to be found by a topic search on subject lines alone
Hi,
I have found some example of R code :
http://commons.wikimedia.org/wiki/File:Mandelbrot_Creation_Animation_%28800x600%29.gif
When I run this code on my computer it takes few seconds.
I wanted to make similar program in Maxima CAS :
Dear R,
I have three matrices like this
K: pp-by-pp commutation matrix,
I: p-by-p diagonal matrix,
X: p-by-q dense matrix,
and I wish to calculate
K(IoX)
where `o' denotes Kronecker product.
Can you give me any suggestion to speed it up when `p' and `q' are large?
Thanks in
I'm wondering if the speed of accessing list element by index is the
same as that of accessing list element by name.
l[[1]]
l[['name']]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
pengyu.ut wrote:
I'm wondering if the speed of accessing list element by index is the
same as that of accessing list element by name.
l[[1]]
l[['name']]
Have you tried answering this question yourself using the system.time()
function?
--
View this message in context:
One way to answer it would be comparing:
system.time(replicate(10^5, l[[1]] ) )
system.time(replicate(10^5, l[['name']] ) )
HTH,
Jorge
On Fri, Dec 4, 2009 at 1:01 AM, Peng Yu wrote:
I'm wondering if the speed of accessing list element by index is the
same as that of accessing list element
Hi, Im new to R and having some trouble with my code - it works, its just
very slow! Ive tried lots of things, but nothing quite seems to work, so any
help and suggestions would be really appreciated!
I want to calculate the marginal likelihood for every element of a row of a
matrix and the
Loops tend to dramatically increase computation time. You may re-write
a vectorized version of your code if possible, i.e. use matrix
algebra. Calculus is a lot faster if one can avoid loops (at least
some of them) .
Best,
Stephane
2009/11/23 AnnaFowler a.fowle...@imperial.ac.uk:
Hi, Im new to
Thanks Stephane, Thats a great help!
SL-16 wrote:
Loops tend to dramatically increase computation time. You may re-write
a vectorized version of your code if possible, i.e. use matrix
algebra. Calculus is a lot faster if one can avoid loops (at least
some of them) .
Best,
Stephane
gauti wrote:
I have been doing series of linear regression models lm(). In this case
the execution time and memory usage becomes a huge issue. I have therefore
been trying to speed the process and limit the memory usage.
Have a look at package biglm.
Dieter
--
View this message
101 - 120 of 120 matches
Mail list logo