Reputation: 1671
Edit: I have plotted a likert scale with 15 different categories (Q002_1 - Q002_15) to answer, see graph down below.
What I now want is to plot this graph (code below) as dichotomous variable with ggplot2, see this question for further details.
I get the following error message:
Error: stat_bin requires the following missing aesthetics: x
I know that I do not see the painful obvious here. Can anyone help me out?
Code:
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)
Upvotes: 1
Views: 5652
Reputation: 3242
competence_bachelor_dich
is not a column in the rawdata
data.frame. If everything eslse is the way it should be your code should work if you add rawdata$competence_bachelor_dich <- competence_bachelor_dich
Upvotes: 2