Re: [R] avoiding a loop: cumsum-like

2006-11-03 Thread Petr Pikal
@stat.math.ethz.ch Subject:[R] avoiding a loop: cumsum-like Hello Rhelpers, I need to run the following loop over a large number of data-sets, and was wondering if it could somehow be vectorized. It's more or less a cumulative sum, but slightly more complex. Here's the code

[R] avoiding a loop: cumsum-like

2006-11-02 Thread GOUACHE David
Hello Rhelpers, I need to run the following loop over a large number of data-sets, and was wondering if it could somehow be vectorized. It's more or less a cumulative sum, but slightly more complex. Here's the code, and an example dataset (called tab in my code) follows. Thanks in advance for

[R] avoiding 'for' loop

2006-10-31 Thread Taka Matzmoto
Hi R users I have a 1000 * 11 matrix (or data.frame). The first 10 columns consist of 0 or 1 (i.e., binary data) and the last column consists of real values. I would like to run a logistic regression with the first binary column as a dependent variable, and the second binary column and the

Re: [R] avoiding a loop

2006-10-26 Thread chao gai
Mark, This is hardly a one-liner. It will only help you if you call it with large objects. If you have 0 in your data it needs even more extending. Here it is: myconstruct - function(aa) { aa - c(1,1,aa,1) bb - cumprod(aa) taa - aa1 difftaa - diff(taa) starts -

Re: [R] avoiding a loop

2006-10-26 Thread Ray Brownrigg
On Wednesday 25 October 2006 07:36, Leeds, Mark (IED) wrote: I think I asked a similar question 3 years ago to the Splus list and I think the answer was no or noone answered so noone should spend more than 5 minutes on this because it could definitely be a waste of time. My question is

[R] avoiding a loop

2006-10-24 Thread Leeds, Mark \(IED\)
I think I asked a similar question 3 years ago to the Splus list and I think the answer was no or noone answered so noone should spend more than 5 minutes on this because it could definitely be a waste of time. My question is whether the function below can be rewritten without a for loop.

Re: [R] avoiding a loop

2006-10-24 Thread Jerome Asselin
On Tue, 2006-10-24 at 14:36 -0400, Leeds, Mark (IED) wrote: I think I asked a similar question 3 years ago to the Splus list and I think the answer was no or noone answered so noone should spend more than 5 minutes on this because it could definitely be a waste of time. My question is

Re: [R] avoiding a loop

2006-10-24 Thread Duncan Murdoch
On 10/24/2006 2:53 PM, Jerome Asselin wrote: On Tue, 2006-10-24 at 14:36 -0400, Leeds, Mark (IED) wrote: I think I asked a similar question 3 years ago to the Splus list and I think the answer was no or noone answered so noone should spend more than 5 minutes on this because it could

Re: [R] avoiding a loop

2006-10-24 Thread Christos Hatzis
) [1] 1.0 1.0 0.5 2.0 3.0 1.2 4.0 5.0 -Christos -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Leeds, Mark (IED) Sent: Tuesday, October 24, 2006 2:36 PM To: R-help@stat.math.ethz.ch Subject: [R] avoiding a loop I think I asked a similar question 3 years

Re: [R] avoiding a loop

2006-10-24 Thread Leeds, Mark \(IED\)
-help@stat.math.ethz.ch Subject: Re: [R] avoiding a loop On Tue, 2006-10-24 at 14:36 -0400, Leeds, Mark (IED) wrote: I think I asked a similar question 3 years ago to the Splus list and I think the answer was no or noone answered so noone should spend more than 5 minutes on this because it could

Re: [R] avoiding a loop

2006-10-24 Thread Leeds, Mark \(IED\)
[mailto:[EMAIL PROTECTED] Sent: Tuesday, October 24, 2006 3:05 PM To: Jerome Asselin Cc: Leeds, Mark (IED); R-help@stat.math.ethz.ch Subject: Re: [R] avoiding a loop On 10/24/2006 2:53 PM, Jerome Asselin wrote: On Tue, 2006-10-24 at 14:36 -0400, Leeds, Mark (IED) wrote: I think I asked a similar

Re: [R] avoiding a loop

2006-10-24 Thread Leeds, Mark \(IED\)
appreciate your help. -Original Message- From: Christos Hatzis [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 24, 2006 3:01 PM To: Leeds, Mark (IED); R-help@stat.math.ethz.ch Subject: RE: [R] avoiding a loop Try this (essentially the trick is to shift the invector to get the y[i-i] effect

[R] avoiding a loop?

2006-10-12 Thread Charles Annis, P.E.
I have a vector, (not a list) repeated.measures.FACTOR.names [1] Insp1 Insp2 Insp3 Insp4 Insp5 Insp6 Insp7 Insp8 Insp9 and would like to convert this into a single string Insp1,Insp2,Insp3,Insp4,Insp5,Insp6,Insp7,Insp8,Insp9 I can do that with a loop, but isn't there a more elegant way?

Re: [R] avoiding a loop?

2006-10-12 Thread Marc Schwartz
On Thu, 2006-10-12 at 12:43 -0400, Charles Annis, P.E. wrote: I have a vector, (not a list) repeated.measures.FACTOR.names [1] Insp1 Insp2 Insp3 Insp4 Insp5 Insp6 Insp7 Insp8 Insp9 and would like to convert this into a single string Insp1,Insp2,Insp3,Insp4,Insp5,Insp6,Insp7,Insp8,Insp9

Re: [R] avoiding a loop?

2006-10-12 Thread Vincent Goulet
Le Jeudi 12 Octobre 2006 12:43, Charles Annis, P.E. a écrit : I have a vector, (not a list) repeated.measures.FACTOR.names [1] Insp1 Insp2 Insp3 Insp4 Insp5 Insp6 Insp7 Insp8 Insp9 and would like to convert this into a single string Insp1,Insp2,Insp3,Insp4,Insp5,Insp6,Insp7,Insp8,Insp9

Re: [R] avoiding a loop?

2006-10-12 Thread Marc Schwartz
On Thu, 2006-10-12 at 12:07 -0500, Marc Schwartz wrote: On Thu, 2006-10-12 at 12:43 -0400, Charles Annis, P.E. wrote: I have a vector, (not a list) repeated.measures.FACTOR.names [1] Insp1 Insp2 Insp3 Insp4 Insp5 Insp6 Insp7 Insp8 Insp9 and would like to convert this into a single

[R] Avoiding for loop

2005-08-04 Thread Matt Crawford
I understand that in R, for loops are not used as often as other languages, and am trying to learn how to avoid them. I am wondering if there is a more efficient way to write a certain piece of code, which right now I can only envision as a for loop. I have a data file that basically looks like:

Re: [R] Avoiding for loop

2005-08-04 Thread Thomas Lumley
On Thu, 4 Aug 2005, Matt Crawford wrote: I understand that in R, for loops are not used as often as other languages, and am trying to learn how to avoid them. I am wondering if there is a more efficient way to write a certain piece of code, which right now I can only envision as a for loop.

Re: [R] Avoiding for loop

2005-08-04 Thread Gabor Grothendieck
On 8/4/05, Matt Crawford [EMAIL PROTECTED] wrote: I understand that in R, for loops are not used as often as other languages, and am trying to learn how to avoid them. I am wondering if there is a more efficient way to write a certain piece of code, which right now I can only envision as a

[R] Avoiding a Loop?

2005-01-21 Thread Rau, Roland
Dear R-Helpers, I have a matrix where the first column is known. The second column is the result of multiplying this first column with a constant const. The third column is the result of multiplying the second column with const. So far, I did it like this (as a simplified example):

RE: [R] Avoiding a Loop?

2005-01-21 Thread Liaw, Andy
If `v' the the vector in the first column and `k' is the constant, then the matrix has k^(j-1) * v in the jth column, right? k - 27.5^seq(0, length=4) k [1] 1.0027.50 756.25 20796.88 outer(1:5, k, *) [,1] [,2][,3] [,4] [1,]1 27.5 756.25 20796.88 [2,]2 55.0

Re: [R] Avoiding a Loop?

2005-01-21 Thread james . holtman
by: cc: [EMAIL PROTECTED]Subject: [R] Avoiding a Loop? ath.ethz.ch

RE: [R] Avoiding a Loop?

2005-01-21 Thread Rau, Roland
PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, January 21, 2005 3:57 PM To: Rau, Roland Cc: r-help@stat.math.ethz.ch; [EMAIL PROTECTED] Subject: Re: [R] Avoiding a Loop? Does this do what you want? nr.of.columns - 4 myconstant - 27.5 mymatrix - matrix(myconstant, nrow=5, ncol

Re: [R] Avoiding a Loop?

2005-01-21 Thread Zoltan Barta
Rau, Roland [EMAIL PROTECTED] writes: Dear R-Helpers, I have a matrix where the first column is known. The second column is the result of multiplying this first column with a constant const. The third column is the result of multiplying the second column with const. So far, I did it

Re: [R] Avoiding a Loop?

2005-01-21 Thread Uwe Ligges
Rau, Roland wrote: Dear R-Helpers, I have a matrix where the first column is known. The second column is the result of multiplying this first column with a constant const. The third column is the result of multiplying the second column with const. So far, I did it like this (as a simplified

RE: [R] Avoiding a Loop?

2005-01-21 Thread Berton Gunter
] [mailto:[EMAIL PROTECTED] On Behalf Of Rau, Roland Sent: Friday, January 21, 2005 4:32 AM To: r-help@stat.math.ethz.ch Subject: [R] Avoiding a Loop? Dear R-Helpers, I have a matrix where the first column is known. The second column is the result of multiplying this first column