我正在使用Likert用于生成图表的 R 包。我有以下最小的 R 示例:
library("likert")
group = c("One", "Two", "One", "Two", "One")
response = c(1, 2, 3, 3, 4)
df = data.frame(response)
levels = c("Strongly Disagree", "Disagree", "Neither Agree nor Disagree", "Agree", "Strongly Agree")
df$response = recode(df$response, from=c(1, 2, 3, 4, 5), to=levels)
df$response = as.factor(df$response)
df$response = factor(df$response, levels=levels)
likert_data = likert(df, grouping=group)
plot(likert_data, legend.position="right", plot.percents=FALSE, plot.percent.low=FALSE, plot.percent.high=FALSE, plot.percent.neutral=FALSE, group.order=c("One", "Two"))
+ ggtitle("Title Here")
+ theme(axis.text.y = element_text(colour="black", size="10", hjust=0))
+ theme(axis.text.x = element_text(colour="black", size="10"))
这会生成一个图表,但是在右侧的“Response”标签中,它只列出了 5 个 Likert 选项中的 4 个。它缺少“强烈同意”,因为它不是一个数据点。
如何强制它在标签中列出所有级别的 Likert 数据?(编辑:已解决,请参阅评论)- 如何将左侧的组标签更改为我指定的名称?
最佳答案
也许可以从这样的事情开始。您必须将 fill = c(1:5) 替换为图表中的颜色。
library(likert)
library(reshape)
plot.new()
plot(likert_data, legend = "", plot.percents=FALSE, plot.percent.low=FALSE, plot.percent.high=FALSE, plot.percent.neutral=FALSE, group.order=c("One", "Two"))
legend(x = .7, y = .5, fill = c(1:5), legend = levels)
关于R Likert 包 - 更改标签级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21443760/