What is the most effective (ie efficient / appropriate) way to clean up a factor containing multiple levels that need to be collapsed? That is, how to combine two or more fa
Perhaps a named vector as a key might be of use:
> factor(unname(c(Y = "Yes", Yes = "Yes", N = "No", No = "No", H = NA)[x])) [1] Yes Yes Yes No No Levels: No Yes
This looks very similar to your last attempt... but this one works :-)