I have a quite simple task: I want to recode a factor into another factor thereby reducing the number of levels. This will be part of a larger data wrangling task.
plyr:revalue let me do this, but recode in dplyr doesn't. At the moment I have a mix of both packages in my code, which I want to avoid as I think it could cause problems due to different maskings of functions and whatever else when transfering the code to other systems.
Any ideas how to solve the problem?
Example code (using revalue):
df <- dataset %>% mutate(prod_type = revalue(dataset$category, c("cars"="durables", "detergents"="cpg", "frozen food"="cpg", "cosmetics"="cpg", "household appliances"="durables", ...)))