[R] ordered factors in data.frame

Greg Snow Greg.Snow at intermountainmail.org
Thu Aug 23 21:21:23 CEST 2007


The attach function only attachs a copy of the data (changes to the data don't show up in the attached copy).  Also you need to tell R what to do with the result of as.ordered (where to save it).

Try something like:

> table$V3 <- as.ordered(table$V3)

Or

> table <- transform(table, V3=as.ordered(V3) )

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Birgit Lemcke
> Sent: Thursday, August 23, 2007 11:28 AM
> To: R Hilfe
> Subject: [R] ordered factors in data.frame
> 
> Hello I need a tiny peace of help. (PPC Mac Os X 10.4.10; R 2.5.1)
> 
> I have a data.frame with numeric and factor variables.
> I would like to convert same of the factors to ordered factors.
> 
> I tried with:
> 
> attach (table)
> 
> as.ordered (V3)
> 
> but this gives me only the V3 Vector as ordred back but in 
> the data.frame (str(Table)) it is still not ordered.
> 
> How can I do that?
> 
> Thanks for your help.
> 
> I am still a beginner.
> 
> Greetings
> 
> Birgit
> 
> Now I would like to
> Birgit Lemcke
> Institut für Systematische Botanik
> Zollikerstrasse 107
> CH-8008 Zürich
> Switzerland
> Ph: +41 (0)44 634 8351
> birgit.lemcke at systbot.uzh.ch
> 
> 
> 
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
>



More information about the R-help mailing list