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
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
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
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
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
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:
>>
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
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
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
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
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
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
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
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
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
-
> 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
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
"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
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
Sent by: cc:
[EMAIL PROTECTED]Subject: [R] Avoiding a Loop?
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
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.
22 matches
Mail list logo