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
Tags:
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