我有一个分数数据框
scores <- data.frame(var1=c(1,3,5,6,1,4,10,2,5,3,7), var2=c(10,9,1,4,3,3,4,7,8,10,10))
我将其转换为具有三个级别的因子:
library(likert)
library(dplyr)
scores_factor <- scores %>% sapply(., cut, c(0, 6, 8, 10), include.lowest = TRUE, labels = c("Negative", "Okay", "Positive")) %>% data.frame
然后将其转换为 likert 项目并使用“likert”包中的 likert.plot 对其进行绘图:
likert_scores <- likert(scores_factor)
p <- plot(likert_scores,
low.color="#ED5949",
neutral.color="#F3CA71",
high.color="#7CB166") +
labs(title= "Hello world!") +
theme(plot.title=element_text(size=16,
face="bold", color="black"),
plot.subtitle=element_text(size=11,
face="italic", color="black"),
text = element_text(color = "#333333",
axis.text.x=element_blank(),
legend.position="right") +
theme_hc()
plot(p)
现在,问题是 likert.plot 显示不在条内的边缘值标签。我希望找到一种方法来打印条内的标签,而不必求助于使用 ggplot2 从头开始构建堆叠的条形图?这可能吗?如果不是,还有什么替代方案?