Re: [R] sapply and loop

2004-10-20 Thread Petr Pikal
Rprof(NULL) summaryRprof() Error in summaryRprof() : no events were recorded Zhen From: Prof Brian Ripley [EMAIL PROTECTED] To: Zhen Pang [EMAIL PROTECTED] CC: [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: [R] sapply and loop Date: Tue, 19 Oct 2004 07:29:54 +0100 (BST) On Tue

Re: [R] sapply and loop

2004-10-19 Thread Prof Brian Ripley
On Tue, 19 Oct 2004, Zhen Pang wrote: I tried to use Rprof(). As an example, I consider the following code (from Venables Ripley, 1999). I believe you parroted that from `Writing R Extensions', but failed to give proper credit! library(MASS); library(boot); library(nls)

Re: [R] sapply and loop

2004-10-19 Thread Zhen Pang
() storm.boot - boot(rs, storm.bf, R = 4999) # pretty slow Rprof(NULL) summaryRprof() Error in summaryRprof() : no events were recorded Zhen From: Prof Brian Ripley [EMAIL PROTECTED] To: Zhen Pang [EMAIL PROTECTED] CC: [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: [R] sapply and loop Date: Tue

Question on Rprof(); was: Re: [R] sapply and loop

2004-10-19 Thread Uwe Ligges
Rprof(NULL) summaryRprof() Error in summaryRprof() : no events were recorded Zhen From: Prof Brian Ripley [EMAIL PROTECTED] To: Zhen Pang [EMAIL PROTECTED] CC: [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: [R] sapply and loop Date: Tue, 19 Oct 2004 07:29:54 +0100 (BST) On Tue, 19 Oct 2004

RE: Question on Rprof(); was: Re: [R] sapply and loop

2004-10-19 Thread Zhen Pang
PROTECTED] Subject: Question on Rprof(); was: Re: [R] sapply and loop Date: Tue, 19 Oct 2004 09:54:39 +0200 Zhen Pang wrote: I am sorry for neglecting the acknowledgement for `Writing R Extensions', since I think I am just citing the code from the orignal R-help. I fail to get the results when I use my

Re: [R] sapply and loop

2004-10-18 Thread Thomas Lumley
On Sat, 16 Oct 2004, Zhen Pang wrote: Dear all, I am doing 200 times simulation. For each time, I generate a matrix and define some function on this matrix to get a 6 dimension vector as my results. As the loop should be slow, I generate 200 matrice first, and save them into a list named ma,

Re: [R] sapply and loop

2004-10-18 Thread Zhen Pang
PROTECTED] Subject: Re: [R] sapply and loop Date: Mon, 18 Oct 2004 09:14:49 -0700 (PDT) On Sat, 16 Oct 2004, Zhen Pang wrote: Dear all, I am doing 200 times simulation. For each time, I generate a matrix and define some function on this matrix to get a 6 dimension vector as my results. As the loop should

[R] sapply and loop

2004-10-16 Thread Mayeul KAUFFMANN
Zhen, how to count the exact time ? system.time(base) Returns CPU (and other) times that expr used. If you only need seconds, you can also do date();zz-sapply(ma, myfunction);date() I do not know about how to reduce the time. For very comlex iterations, I use for( ) myself, which maybe

Re: [R] sapply and loop

2004-10-16 Thread Roger D. Peng
You can use system.time() to time your procedure. There's no guarantee that sapply() will be faster than a for() loop, especially if you preallocate the matrices. -roger Zhen Pang wrote: Dear all, I am doing 200 times simulation. For each time, I generate a matrix and define some function on

RE: [R] sapply and loop

2004-10-16 Thread Liaw, Andy
Without seeing what myfunction is, it's almost impossible to tell. In addition to system.time(), you might want to profile your code. e.g., Rprof() zz - sapply(ma, myfunction) Rprof(NULL) summaryRprof() HTH, Andy From: Zhen Pang Dear all, I am doing 200 times simulation. For each time,

RE: [R] sapply and loop

2004-10-16 Thread Zhen Pang
PROTECTED] To: 'Zhen Pang' [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: RE: [R] sapply and loop Date: Sat, 16 Oct 2004 08:23:54 -0400 Without seeing what myfunction is, it's almost impossible to tell. In addition to system.time(), you might want to profile your code. e.g., Rprof() zz - sapply(ma

[R] sapply and loop

2004-10-15 Thread Zhen Pang
Dear all, I am doing 200 times simulation. For each time, I generate a matrix and define some function on this matrix to get a 6 dimension vector as my results. As the loop should be slow, I generate 200 matrice first, and save them into a list named ma, then I define zz-sapply(ma, myfunction)