R Likert 包 - 更改标签级别

标签 r graphing

我正在使用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/

相关文章:

javascript - 如何向浮点图中添加一个新的单点?

python - 有没有适用于 Python 3.0 的图形/绘图/类似库?

function - SciLab 绘图

java - JFreeChart 日期轴格式化问题

r - 每第 n 个范围递增 R

多列滚动回归

r - 使 ggplot 完全适合视口(viewport)大小

python - 如果在 Matplotlib 中指定图形大小,图形标题 (suptitle()) 会消失

r - 非参数逆(累积)分布函数

r - 忽略循环中的错误,使用循环命名数据帧