I have a survey data with respondents answering multiple questions.
In one variable, respondents express their opinion about a party "1" = favorable and "0" = unfavorable.
In the second variable, they rate an issue as "1" = major threat, or "2" = minor threat or "3" = not a threat.
ID Country PartyOP ThreatPercp
1 France 1 2
2 France 1 3
3 France 0 1
4 France 1 1
5 France 0 2
My theory is that those with favorable opinion about the party are more likely to see the issue as a threat.
I want the stacked bar to show the following
X-axis: PartyOpinion Y-Axis: count or percentage or frequency color: ThreatPercp
I tried the following but it didn't work. The "fill" did not display anything
ggplot(data = France) +
geom_bar(aes(x = PartyOp)) +
labs(x = "Party Opinion",
y = "Count")
+ geom_col(aes(fill = ThreatPercp), width = 0.7)
+ theme_bw()
Any idea how to nail the stacked bar chart?