@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
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
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
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
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.
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
)
[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
-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
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?
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
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:
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
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):
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
by: cc:
[EMAIL PROTECTED]Subject: [R] Avoiding a Loop?
ath.ethz.ch
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
]
[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
26 matches
Mail list logo