[R] Merging value labels into indicator variable.
Peter.Brecknock at bp.com
Tue Feb 26 18:51:51 CET 2013
> I have a vaiable named NAM having value : 1,2,3,4,5,6,7,8,9. I want to
> make an indicator variable that will take value 1 if NAM=7 or NAM=8 or
> NAM=9. How can I do that?
> I usually do: Var001<- ifelse(NAM==7,1,0) for the simplest case.
> [[alternative HTML version deleted]]
> mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
How about something like ...
NAM = c(1,2,3,4,5,6,7,8,9)
ifelse(NAM %in% c(7,8,9),1,0)
View this message in context: http://r.789695.n4.nabble.com/Merging-value-labels-into-indicator-variable-tp4659703p4659705.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help