Re: [R] change factor labels

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.be>
Date: Tue 18 Oct 2005 - 20:39:14 EST

one way is to use:

levels(test$x) <- c("u", "v")

I hope it helps.

Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


> it must be terribly simple, can someone quickly help me?
>
> test <- data.frame(y=c(1:10), x=as.factor(c(rep("a",5),rep("b",5))))
>
> how can i change the factor labels from "a" and "b" to for example
> "u" and
> "v"?
>
> i don't succeed with factor()
>
> thanks a lot
>
> ------------------------------------------------
> Sebastian Leuzinger
> Institute of Botany, University of Basel
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Oct 18 20:42:04 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 19:01:19 EST