r李克特图编辑



我正在使用r软件包李克特根据问卷来制作图形。这些图基本上只是偏好频谱,看起来非常类似于此preprex(没有原始数据,无法披露):

data("pisaitems")
title <- "How often do you read these materials because you want to?"
items29 <- pisaitems[,substr(names(pisaitems), 1,5) == 'ST25Q']
head(items29); ncol(items29)
names(items29) = c("Magazines", "Comic books", "Fiction", "Non-fiction books", "Newspapers")
l29 <- likert(items29)
str(l29)
l29s <- likert(summary = l29$results)
str(l29s)
scale_height = knitr::opts_chunk$get('fig.height')*0.5
scale_width = knitr::opts_chunk$get('fig.width')*1.25
knitr::opts_chunk$set(fig.height = scale_height, fig.width = scale_width)
theme_update(legend.text = element_text(size = rel(0.7)))
plot(l29s) + ggtitle(title)

所以这是我的问题:

  1. 我正在为一家德国公司进行此分析,我似乎无法摆脱图表中的"百分比"?
  2. 如何将轴上的壁虱更改为10%增量?
  3. 如何将项目名称与左侧和标题中心对齐?我如何将传奇与左下角对齐?

我设法将大部分图表设置放到了我的偏好中,但是最后3个不断避开我。

fyi:从此站点生成示例:https://rpubs.com/m_dev/likert_summary

李克特软件包的绘图函数返回ggplot对象。您可以像往常一样更新/覆盖该对象的各个方面。(您已经在+ ggtitle()的最后一行中完成了一次。

进一步注意,绘图是旋转的,因此有时您需要参考y轴,旋转后---将其显示为x轴。

我解决了您的前两个问题,并将第三个问题作为您或其他人的练习。

library(likert)
data(pisaitems)
title <- "How often do you read these materials because you want to?"
items29 <- pisaitems[, substr(names(pisaitems), 1,5) == 'ST25Q']
names(items29) <- c("Magazines", "Comic books", "Fiction", "Non-fiction books", "Newspapers")
l29 <- likert(items29)
l29s <- likert(summary = l29$results)
# Make axis tick labels left aligned with 'axis.text.y'
theme_update(legend.text = element_text(size = rel(0.7)),
             axis.text.y = element_text(hjust = 0))
# Override default label for axis with 'labs()'
# Override breaks of axis with 'continuous_scale()'
plot(l29s) + 
    labs(title = title, y = "Prozent") +
    scale_y_continuous(labels = likert:::abs_formatter, lim = c(-100, 100),
                       breaks = seq(-100, 100, 25))

最新更新