[R] PROBLEMS with In `[<-.factor`(`*tmp*`, (¿ORDERED FACTOR?)

arun smartpink111 at yahoo.com
Wed May 30 00:09:56 CEST 2012


HI,

Do you want to replace the column ("level of education") with values or just add values as second column?  I guess you are looking for the latter.


Try this,

dat<-data.frame(Levelofeducation=rep(c("none","HighSchool","College"),c(3,3,3)),value=rep(c(0,1,2),c(3,3,3)))
str(dat)

data.frame':    9 obs. of  2 variables:
 $ Levelofeducation: Factor w/ 3 levels "College","HighSchool",..: 3 3 3 2 2 2 1 1 1
 $ value           : num  0 0 0 1 1 1 2 2 2

> dat
  Levelofeducation value
1             none     0
2             none     0
3             none     0
4       HighSchool     1
5       HighSchool     1
6       HighSchool     1
7          College     2
8          College     2
9          College     2

A.K.





----- Original Message -----
From: RBB <raulbajob at gmail.com>
To: r-help at r-project.org
Cc: 
Sent: Tuesday, May 29, 2012 2:01 PM
Subject: [R] PROBLEMS with In `[<-.factor`(`*tmp*`, (¿ORDERED FACTOR?)

HI!!!

I have a table containing qualitative and quantitative data; one of the
columns contains  "Level of education", and the possibilities are "none",
"High school", "college"; I want to give the value 0 to "none", the value 1
to "High school", and 2 to "college", but I got the following error: 

In `[<-.factor`(`*tmp*`, educa = "college", value = 2) :
  invalid factor level, NAs generated


WHAT IS WRONG????? :S :S :S 


THANKS A LOT!!!!!!!!!!!!!!

--
View this message in context: http://r.789695.n4.nabble.com/PROBLEMS-with-In-factor-tmp-ORDERED-FACTOR-tp4631736.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at r-project.org 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