[R] reodering factor

Seyed Reza Jafarzadeh srjafarzadeh at gmail.com
Fri May 4 04:55:37 CEST 2007


Hi John,

You should use (http://rweb.stat.umn.edu/R/library/stats/html/relevel.html), so

newGroup <- relevel (data$Group, ref = "ZZ")



Reza


On 5/3/07, John Sorkin <jsorkin at grecc.umaryland.edu> wrote:
> R 2.4.1
> Windows XP
>
> How does one reorder a factor?
>
>
> I have the following data:
> > factor(data$Group)
>  [1] ZZ ZT ZT ZZ ZZ ZT ZZ ZZ ZT ZT ZT ZT ZZ ZT ZT ZZ ZT ZZ ZT ZZ ZT ZT ZZ ZZ ZT ZZ ZT ZZ ZT ZZ ZZ ZT ZZ ZT
> Levels: ZT ZZ
>
> In my regression (i.e. lm(y~data$Group) ZT is taken as the reference category and I get an estimate for ZZ. I would like ZZ to be the reference category and obtain an estimate for ZT.
>
> Thank,
> John
>
> John Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>
> Confidentiality Statement:
> This email message, including any attachments, is for the so...{{dropped}}
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list