I'm working with one categorical variable which lays out ethnicities from census data. I've already renamed the categories from 1,2,3 etc to the codebook names of the various ethnicities but some of them overlap and are really small, like a few observations each. How can I merge categories like "White&Black Caribbean", "White&Black African", "White Asian" into a single category which is just "Mixed ethnicity"
This is what I've got coded so far, I'm brand new to R as a student any help would be appreciated.
table(d$y11, useNA = "ifany")
d$y11<-factor(d$y11, labels = c("British","Irish","Gypsy/Irish Traveller","Any other White","White&Black Caribbean","White&Black African","White Asian","Any other mixed","Indian","Pakistani","Bangladeshi","Chinese","Any Other Asian","African","Caribbean","Any other Black","Arab","Any Other group","Prefer not to say"))
I tried testing with just two using dplyr
d$y11 <- combine(d$y11, name = "Mixed Ethnicity", combinations = list("Mixed Ethnicity" = "White&Black Caribbean","White&Black African"))
but just got a series of errors I don't understand at all.
Error in
vec_c()
: ! Can't combine..1
and..3
. Runrlang::last_trace()
to see where the error occurred. Warning message:combine()
was deprecated in dplyr 1.0.0. ℹ Please usevctrs::vec_c()
instead. Calllifecycle::last_lifecycle_warnings()
to see where this warning was generated. rlang::last_trace() <error/vctrs_error_ptype2> Error invec_c()
: ! Can't combine..1
and..3
.
I also tried using Merge which didn't work either