Hi
I have not seen any answer yet so I wil try (partly).
I believe that the loop can be vectorised but I am a little bit lost
in your fors and ifs. I found that first part of res is same as
cumsum(tab$x.jour) until about 81st value. However I did not decipher
how to compute the remaining
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 -
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
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
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
Try this (essentially the trick is to shift the invector to get the y[i-i]
effect):
constructLt-function(invector, a=1) {
invector[invectora] - c(0,invector)[invectora] * invector[invectora]
invector
}
aa - c(1,1,0.5,2,3,0.4,4,5)
aa
[1] 1.0 1.0 0.5 2.0 3.0 0.4 4.0 5.0
constructLt(aa)
-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
[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
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
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
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
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
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.
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
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
Does this do what you want?
nr.of.columns - 4
myconstant - 27.5
mymatrix - matrix(myconstant, nrow=5, ncol=nr.of.columns)
mymatrix[,1] - 1:5
t(apply(mymatrix, 1, function(x) cumprod(x)))
__
James HoltmanWhat is the problem
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
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
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
Roland:
Andy Liaw and others have already given perfectly good answers to this (but
note: Using apply() type functions does **not** avoid loops; apply's **are**
loops). However, mostly as an illustration to reinforce Uwe Ligges's
comments (in the dim vs length thread) about the usefulness of
20 matches
Mail list logo