I notice that in R, if you use levels to change the order of the levels in a factor column, you actually change the content of the data. For example:
test <- data.frame(name=c("A","B","C"), age=c(20,21,22))
test$name <- as.factor(test$name)
levels(test$name) <- c("C","B","A")
Then in test, it becomes that C has age 20, A has age 22, instead of the original content where A has age 20 and C has age 22.
How can I change the levels of a factor without changing the actual content?