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

2006-11-03 Thread Petr Pikal
L PROTECTED]> To: 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, b

[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 an

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

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 <- aa<1 difftaa <- diff(taa) starts <- which(c(FALSE

Re: [R] avoiding a loop

2006-10-24 Thread Leeds, Mark \(IED\)
I do 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] e

Re: [R] avoiding a loop

2006-10-24 Thread Leeds, Mark \(IED\)
an Murdoch [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: >>

Re: [R] avoiding a loop

2006-10-24 Thread Leeds, Mark \(IED\)
2:54 PM To: Leeds, Mark (IED) Cc: R-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

Re: [R] avoiding a loop

2006-10-24 Thread Christos Hatzis
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 ago to the Splus list and I think the answer was

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 coul

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

[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. apply

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

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

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,I

[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

RE: [R] Avoiding a Loop?

2005-01-21 Thread Berton Gunter
- > From: [EMAIL PROTECTED] > [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 se

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 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 fa

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, nro

Re: [R] Avoiding a Loop?

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

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

[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): nr.of.