'Cannot show the labels of factor correct

I had defined major into factor, but the labels still shows "I" and "D", and not in the correct order. What is the problem?

major <- factor(major, levels = c("I","D"), labels = c("Information", "Documentation"))

major
[1] Information   Information   Information   Information   Information   Information  
[7] Information   Documentation Documentation Documentation Documentation Information  
[13] Information   Information   Information   Information   Documentation Documentation
[19] Documentation Documentation Documentation Documentation Documentation Documentation
[25] Documentation Documentation Documentation Information   Information   Information  
[31] Information   Information   Information   Information   Information   Information  
[37] Information   Documentation Documentation Documentation Documentation Documentation
[43] Information   Information   Information   Information   Information   Information  
[49] Information   Documentation Documentation Documentation Documentation Documentation
Levels: Information Documentation

ggplot(kaoyan,aes(year,score1))+
    geom_point()+
    facet_wrap(~major)
r


Solution 1:[1]

The major variable that you were transforming was not in your data frame, it was a different separate variable.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user2974951