Replace a value in a data frame based on a conditional (`if`) statement
Easier to convert nm to characters and then make the change: junk$nm <- as.character(junk$nm) junk$nm[junk$nm == “B”] <- “b” EDIT: And if indeed you need to maintain nm as factors, add this in the end: junk$nm <- as.factor(junk$nm)