我确定您的变量被归类为一个因素。因此,只需使用这种方法合并一些因素。
set.seed(42) # for reproducibility
# mimicking your data
df1 <- data.frame(var=rdunif(100, 10))
df1$var <- factor(df1$var, 1:10, labels=c("Couldn't be worse", "Very bad",
"Bad", "Meh", "So-so", "Okay",
"Good", "Very Good", "Great",
"Really great"))
df1$var1 <- df1$var
# merging levels
levels(df1$var1) <- list("Very negative"=c("Couldn't be worse", "Very bad"),
"negative" = c("Bad", "Meh"),
"neutral" = c("So-so", "Okay"),
"positive"=c("Good", "Very Good"),
"very positive"=c("Great", "Really great"))
屈服
> tail(df1, 10)
var var1
91 Very bad Very negative
92 Very Good positive
93 Very bad Very negative
94 Very bad Very negative
95 Couldn't be worse Very negative
96 Couldn't be worse Very negative
97 Okay neutral
98 Very bad Very negative
99 Very Good positive
100 Very Good positive