Use levels().

> x <- as.factor(c("A", "B", "C", "D", "B", "A")) > x [1] A B C D B A Levels: A B C D > levels(x)[levels(x) == "D"] <- "C" > x [1] A B C C B A Levels: A B C

Use levels().

> x <- as.factor(c("A", "B", "C", "D", "B", "A")) > x [1] A B C D B A Levels: A B C D > levels(x)[levels(x) == "D"] <- "C" > x [1] A B C C B A Levels: A B C

## Post a Comment