I have imported a table (.cvs) in R, which has a column for income, where the income is given as either <=50K
or >50K
.
>str(hausuebung_daten$income)
chr [1:500] "<=50K""<=50K"">50K""<=50K"">50K""<=50K""<=50K""<=50K"">50K""<=50K"">50K"">50K" ...
Now I am trying to convert this column from character to numeric. I have been able to convert it to factor
> hausuebung_daten$income<-factor(hausuebung_daten$income)
> str(hausuebung_daten$income)
Factor w/ 2 levels "<=50K",">50K": 1 1 2 1 2 1 1 1 2 1 ...
And then tried assigning the factors a numerical value (using the plyr package)
library(plyr)
> hausuebung_daten$income<-revalue(hausuebung_daten$income, "1"="<=50000", "2"=>"50000")
Error: unexpected '>' in "hausuebung_daten$income<-revalue(hausuebung_daten$income, "1"="<=50000", "2"=>"
and I get the error message as shown above.