Re: [R] SAS-like method of recoding variables?

2009-06-23 Thread Dieter Menne
P.Dalgaard wrote: IF TYPE='TRUCK' and count=12 THEN VEHICLES=TRUCK+((CAR+BIKE)/2.2); vehicles - ifelse(TYPE=='TRUCK' count=12, TRUCK+((CAR+BIKE)/2.2), NA) Read both versions to an audience, and you will have to admit that this is one of the cases where SAS is superior. Dieter

Re: [R] SAS-like method of recoding variables?

2009-06-23 Thread Peter Dalgaard
Dieter Menne wrote: P.Dalgaard wrote: IF TYPE='TRUCK' and count=12 THEN VEHICLES=TRUCK+((CAR+BIKE)/2.2); vehicles - ifelse(TYPE=='TRUCK' count=12, TRUCK+((CAR+BIKE)/2.2), NA) Read both versions to an audience, and you will have to admit that this is one of the cases where SAS is

Re: [R] SAS-like method of recoding variables?

2009-06-23 Thread Simon Blomberg
that a reasonable answer can be extracted from a given body of data. - John Tukey. -Original Message- From: r-help-boun...@r-project.org on behalf of Dieter Menne Sent: Tue 23/06/2009 4:43 PM To: r-help@r-project.org Subject: Re: [R] SAS-like method of recoding variables? P.Dalgaard wrote

Re: [R] SAS-like method of recoding variables?

2009-06-23 Thread Dieter Menne
Simon Blomberg-4 wrote: I'm not sure we should measure superiority by how well a statement parses into English. If this were true, we would all be programming in COBOL. P.Dalgaard wrote: IF TYPE='TRUCK' and count=12 THEN VEHICLES=TRUCK+((CAR+BIKE)/2.2); vehicles -

Re: [R] SAS-like method of recoding variables?

2009-06-23 Thread Peter Flom
Dieter Menne wrote: IF TYPE='TRUCK' and count=12 THEN VEHICLES=TRUCK+((CAR+BIKE)/2.2); vehicles - ifelse(TYPE=='TRUCK' count=12, TRUCK+((CAR+BIKE)/2.2), NA) Read both versions to an audience, and you will have to admit that this is one of the cases where SAS is superior. And Peter

Re: [R] SAS-like method of recoding variables?

2009-06-23 Thread David Hajage
You can also use if (cond) then {something} if you don't like ifelse() function. See ?Control. David 2009/6/23 Peter Flom peterflomconsult...@mindspring.com Dieter Menne wrote: IF TYPE='TRUCK' and count=12 THEN VEHICLES=TRUCK+((CAR+BIKE)/2.2); vehicles - ifelse(TYPE=='TRUCK' count=12,

Re: [R] SAS-like method of recoding variables?

2009-06-23 Thread Dieter Menne
David Hajage-2 wrote: You can also use if (cond) then {something} if you don't like ifelse() function. See ?Control. The minor difference that if() is not vectorized is a source of FAQs. Dieter -- View this message in context:

Re: [R] SAS-like method of recoding variables?

2009-06-23 Thread David Winsemius
On Jun 23, 2009, at 7:40 AM, David Hajage wrote: You can also use if (cond) then {something} if you don't like ifelse() function. See ?Control. Had you followed you own advice, you should have seen why this is completely misleading in the curret context. cond A length-one logical vector

Re: [R] SAS-like method of recoding variables?

2009-06-23 Thread Frank E Harrell Jr
Dieter Menne wrote: P.Dalgaard wrote: IF TYPE='TRUCK' and count=12 THEN VEHICLES=TRUCK+((CAR+BIKE)/2.2); vehicles - ifelse(TYPE=='TRUCK' count=12, TRUCK+((CAR+BIKE)/2.2), NA) Read both versions to an audience, and you will have to admit that this is one of the cases where SAS is

Re: [R] SAS-like method of recoding variables?

2009-06-23 Thread Dieter Menne
Frank E Harrell Jr wrote: Here's a case where SAS is clearly not superior: IF type='TRUCK' AND count12 THEN vehicles=truck+(car+bike)/2.2; If count is missing, the statement is considered TRUE and the THEN is executed. This is because SAS considers a missing as less than any

Re: [R] SAS-like method of recoding variables?

2009-06-23 Thread David Freedman
Frank, would you feel comfortable giving us the reference to the NEJM article with the 'missing vs ' error ? I'm sure that things like this happen fairly often, and I'd like to use this example in teaching thanks, david freedman Frank E Harrell Jr wrote: Dieter Menne wrote: P.Dalgaard

Re: [R] SAS-like method of recoding variables?

2009-06-23 Thread Frank E Harrell Jr
David Freedman wrote: Frank, would you feel comfortable giving us the reference to the NEJM article with the 'missing vs ' error ? I'm sure that things like this happen fairly often, and I'd like to use this example in teaching thanks, david freedman @ARTICLE{gus93int, author = {{The GUSTO

[R] SAS-like method of recoding variables?

2009-06-22 Thread Mark Na
Dear R-helpers, I am helping a SAS user run some analyses in R that she cannot do in SAS and she is complaining about R's peculiar (to her!) way of recoding variables. In particular, she is wondering if there is an R package that allows this kind of SAS recoding: IF TYPE='TRUCK' and count=12

Re: [R] SAS-like method of recoding variables?

2009-06-22 Thread David Winsemius
On Jun 22, 2009, at 2:27 PM, Mark Na wrote: Dear R-helpers, I am helping a SAS user run some analyses in R that she cannot do in SAS and she is complaining about R's peculiar (to her!) way of recoding variables. In particular, she is wondering if there is an R package that allows this kind of

Re: [R] SAS-like method of recoding variables?

2009-06-22 Thread Chuck Cleland
On 6/22/2009 2:27 PM, Mark Na wrote: Dear R-helpers, I am helping a SAS user run some analyses in R that she cannot do in SAS and she is complaining about R's peculiar (to her!) way of recoding variables. In particular, she is wondering if there is an R package that allows this kind of SAS

Re: [R] SAS-like method of recoding variables?

2009-06-22 Thread Peter Dalgaard
Mark Na wrote: Dear R-helpers, I am helping a SAS user run some analyses in R that she cannot do in SAS and she is complaining about R's peculiar (to her!) way of recoding variables. In particular, she is wondering if there is an R package that allows this kind of SAS recoding: IF TYPE='TRUCK'