[R] change factor labels

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Tue Oct 18 12:39:14 CEST 2005


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


----- Original Message ----- 
From: "Sebastian Leuzinger" <Sebastian.Leuzinger at unibas.ch>
To: <r-help at stat.math.ethz.ch>
Sent: Tuesday, October 18, 2005 12:19 PM
Subject: [R] change factor labels


> 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 at 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




More information about the R-help mailing list