编辑:我已经绘制了一个具有15个不同类别(Q002_1 - Q002_15)的Likert量表来回答,请参阅下面的图表。
我现在想要的是将此图(下面的代码)绘制为ggplot2的二分变量,有关详细信息,请参阅this question。
我收到以下错误消息:
错误:stat_bin需要以下缺失的美学:x
我知道我在这里看不到明显的痛苦。任何人都可以帮助我吗?
代码:
competence_bachelor_dich <- competence_bachelor # dichotomous variable
levels(competence_bachelor_dich) <- list("0" = c("insignificant", "2", "3"),
"1" = c("8", "9", "very relevant"))
ggplot(rawdata, aes(x = competence_bachelor_dich)) +
geom_histogram() + xlab("") + ylab("Number of participants") +
scale_x_discrete(labels = "0", "1") +
ggtitle("How do you rate your skills gained with the Bachelor's?") +
theme(axis.text.y = element_text(colour = "black"),
axis.text.x = element_text(colour = "black"))
ggsave((filename = "competence_bachelor_dich.pdf"),
scale = 1, width = par("din")[1],
height = par("din")[2], units = c("in", "cm", "mm"),
dpi = 300, limitsize = TRUE)
答案 0 :(得分:2)
competence_bachelor_dich
不是rawdata
data.frame中的列。如果添加rawdata$competence_bachelor_dich <- competence_bachelor_dich