[datatable-help] Replacing NA values for a categorical variable results in numerical replacements

Memo712 amin.f.saad at gmail.com
Thu Nov 24 01:06:04 CET 2016


Dear forum members, 

I am new to R and I have downloaded the car library and I am working with
the Prestige database. 
In this database, I am trying to replace replace NA value for a Factor
variable called type and I used the following code. 

Prestige.bc <- Prestige %>% mutate(type = ifelse(is.na(type),"bc",type))

I was successful in doing that but the other values, which were prof, bc,
wc, changed to  numbers 2. 3 and 1 and only NA were replaced by bc. For
example:

type 
2
2
3
1
bc
1
3
3
2

I really appreciate any help. 



--
View this message in context: http://r.789695.n4.nabble.com/Replacing-NA-values-for-a-categorical-variable-results-in-numerical-replacements-tp4726789.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list