A (Bob)
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Multiple Conditional Tranformations
And here is a variation:
transform(mydata,
score1 = (2 + (gender == m)) * q1 + q2,
score2 = score1 + 0.5 * q1
)
or
transform(
transform(mydata, score1 = (2 + (gender == m)) * q1 + q2),
score2
]
Sent: Saturday, November 25, 2006 12:39 AM
To: Muenchen, Robert A (Bob)
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Multiple Conditional Tranformations
And here is a variation:
transform(mydata,
score1 = (2 + (gender == m)) * q1 + q2,
score2 = score1 + 0.5 * q1
)
or
transform
-Original Message-
From: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
Sent: Saturday, November 25, 2006 7:37 AM
To: Muenchen, Robert A (Bob)
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Multiple Conditional Tranformations
Firstly your outline does not check once, it checks twice. First it
check
@stat.math.ethz.ch
Subject: Re: [R] Multiple Conditional Tranformations
Firstly your outline does not check once, it checks twice. First it
check for m and then it redundantly checks for f. On the other
hand the two variations in my post do check once.
Although substantially longer than the solutions
, Robert A (Bob)
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Multiple Conditional Tranformations
Firstly your outline does not check once, it checks twice. First it
check for m and then it redundantly checks for f. On the other
hand the two variations in my post do check once
, 2006 11:11 AM
To: Muenchen, Robert A (Bob)
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Multiple Conditional Tranformations
Here is a correction:
do.call(rbind, by(mydata, 1:nrow(mydata), function(x)
switch(as.character(x$gender),
m = transform(x, score1 = 3*q1+q2, score2 = 3.5*q1+q2),
f
Greetings,
I'm learning R and I'm stuck on a basic concept: how to specify a
logical condition once and then perform multiple transformations under
that condition. The program below is simplified to demonstrate the goal.
Its results are exactly what I want, but I would like to check the
) [mailto:[EMAIL PROTECTED]
Sent: Friday, November 24, 2006 8:45 PM
To: Muenchen, Robert A (Bob)
Subject: RE: [R] Multiple Conditional Tranformations
I'm not sure if I understand your question but I don't think you need
iflelse statements.
myscore-numeric(q1) ( because I'm not sure how
=
-Original Message-
From: Leeds, Mark (IED) [mailto:[EMAIL PROTECTED]
Sent: Friday, November 24, 2006 8:45 PM
To: Muenchen, Robert A (Bob)
Subject: RE: [R] Multiple Conditional Tranformations
I'm not sure if I understand your question but I don't think you need
iflelse statements.
myscore
Good idea. I'm still getting used to how flexible R is on substitutions
like that! -Bob
-Original Message-
From: Leeds, Mark (IED) [mailto:[EMAIL PROTECTED]
Sent: Friday, November 24, 2006 10:20 PM
To: Muenchen, Robert A (Bob)
Subject: RE: [R] Multiple Conditional Tranformations
You
: Friday, November 24, 2006 8:45 PM
To: Muenchen, Robert A (Bob)
Subject: RE: [R] Multiple Conditional Tranformations
I'm not sure if I understand your question but I don't think you need
iflelse statements.
myscore-numeric(q1) ( because I'm not sure how to initialize a list so
initialize a vector
) [mailto:[EMAIL PROTECTED]
Sent: Friday, November 24, 2006 8:45 PM
To: Muenchen, Robert A (Bob)
Subject: RE: [R] Multiple Conditional Tranformations
I'm not sure if I understand your question but I don't think you need
iflelse statements.
myscore-numeric(q1) ( because I'm not sure how
12 matches
Mail list logo