On Fri, 19 Sep 2014 12:53:16 PM Angel Rodriguez wrote:
> Dear Subscribers,
> 
> I want to label a numeric variable 0="Bad" /1="Good". I understand 
the only
> way is to transform it into a factor variable.
> 
> Is there a way to check that the numeric values of the new factor 
variable
> are 0 and 1 and not 1 and 2?
> 
> Thank you very much.
> 
> Angel Rodriguez-Laso
> 
Hi Angel,
As far as I know, the numeric values of factors always begin with 1. If your 
factor (badgood) is constructed from the values "Bad" and "Good":

as.numeric(badgood) - 1

will produce a vector of zeros and ones.

If you have a numeric vector of zeros and ones and want the 
corresponding vector of "Bad" and "Good":

ifelse(badgood,"Good","Bad")

Jim

______________________________________________
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