I have a categorical variable educa that needs to be converted into numbers for readability. educa can take on 6 values. I want to convert them into 1-6. How do I do this? This doesn't work: brfs2013educationsummarycleaned % mutate( educa_level = ifelse(educa == "Never attended school or only kindergarten", 1, educat == "Grades 1 through 8 (Elementary)", 2, "not a real category")) What am I doing wrong? The above is a portion of what I intend to do. Solved We can use match if the values in 'educa' have to be converted based on the order in which they appear in the data library(tidyverse) brfs2013educationsummary %>% mutate(educa_level = match(educa, unique(educa))) as.numeric(educa) will do what you want and if you want it as new column brfs2013educationsummarycleaned % mutate(educa_level = as.numeric(educa))