我正在使用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个。它缺少“非常同意”,因为它不是数据点。
答案 0 :(得分:2)
也许像这样的开始。您必须使用图表中的颜色替换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)