Which is the proper way to rename a factor? If I do: test$Parc[test$Parc=="Ol?rdola"]<-"Ol?rdola" R complains that Warning message: invalid factor level, NAs generated in: `[<-.factor`(`*tmp*`, test$Parc == "Ol?rdola", value = "Ol?rdola") Thanks Agus -- Dr. Agustin Lobo Institut de Ciencies de la Terra "Jaume Almera" (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: Agustin.Lobo at ija.csic.es ija.csic.es/gt/obster
Try: levels(test$Parc)[levels(test$Parc)=="OlÞrdola"] <- "Olèrdola" -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O On 24/07/07, Agustin Lobo <Agustin.Lobo@ija.csic.es> wrote:> > Which is the proper way to rename a factor? > If I do: > test$Parc[test$Parc=="OlÞrdola"]<-"Olèrdola" > R complains that > Warning message: > invalid factor level, NAs generated in: `[<-.factor`(`*tmp*`, test$Parc > == "OlÞrdola", value = "Olèrdola") > > Thanks > Agus > -- > Dr. Agustin Lobo > Institut de Ciencies de la Terra "Jaume Almera" (CSIC) > LLuis Sole Sabaris s/n > 08028 Barcelona > Spain > Tel. 34 934095410 > Fax. 34 934110012 > email: Agustin.Lobo@ija.csic.es > ija.csic.es/gt/obster > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]