Thanks a lot Greg for your help. This works fine.
Normally I use a vector to set the classes for the variables: Classe<-cclasses <- c(rep("factor", 14), rep("numeric", 4)) Table1<-read.table("Name", sep = ";", colClasses = Classe) How can I implement to set colClasses as ordererd factor here. Following works not: Classe<-cclasses <- c(rep("factor", 61), rep("numeric", 14), rep ("odered", 10)) Thanks in advance Birgit Am 23.08.2007 um 21:21 schrieb Greg Snow: > 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 > [EMAIL PROTECTED] > (801) 408-8111 > > > >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] 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 >> [EMAIL PROTECTED] >> >> >> >> >> >> >> [[alternative HTML version deleted]] >> >> > Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]]
______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.