> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Jeff
> Sent: Tuesday, July 10, 2012 5:26 PM
> To: r-help
> Subject: [R] ifelse help
> 
> 
> I'm sure this is easy, but I'm new to R and can't find any example of
> the following.
> 
> Here's what I'm trying to do in pseudo-code.
> 
> data$newvar <- ifelse(data$oldvar1 == 8, 1,data$oldvar2)
> 
> In other words, if the existing variable equals 8, then the new
> variable should equal 1, otherwise the new variable should equal the
> value of another existing variable.
> 
> I've tried to follow the examples given on the web and in the R
> manuals, and each time I get errors or unexpected values.
> 
> Thanks
> 
> Jeff
> 

Rather than tell us that you tried some examples and they didn't work, show us 
what you tried (i.e. a reproducible example as requested in the posting guide) 
so that we can play along at home. :-)  

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to