1

编辑:我绘制了一个包含 15 个不同类别(Q002_1 - Q002_15)的李克特量表来回答,见下图。

我现在想要的是将此图(下面的代码)绘制为带有 ggplot2 的二分变量,有关详细信息,请参阅此问题

我收到以下错误消息:

错误: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)

在此处输入图像描述

4

1 回答 1

2

competence_bachelor_dich不是rawdatadata.frame 中的列。如果一切都是这样,那么如果您添加,您的代码应该可以工作rawdata$competence_bachelor_dich <- competence_bachelor_dich

于 2014-04-01T14:18:56.713 回答