I want to plot a bar chart and use scale_x_discrete
to manually describe the bars. The x variable has 9 levels, the group-variable has 3 levels.
ggplot(data, aes(x = education, group = food, fill = food)) +
geom_bar() +
scale_x_discrete(limits=c("A","B","C","D","E","F","G","H","I"))
I did the same plot with the two other x-variables and it worked perfectly. This one works without the scale_x_discrete
function, but as soon as I use it to give shorter names to the bars, I get the following error:
Warning message: Removed 979 rows containing non-finite values (stat_count).
There are no NAs, but for some levels of x there is only one level of the group-variable "food", which isn't the case for the other variables I plotted, so that might be part of the problem. What could be a solution?