I want to analysis covid situation for 2020 vs 2021 and want to show how contagious virus in 2021 using ggplot
df <- data.frame(
self_impact = as.factor(c("Y", "Y", "Y", "N", "N", "Y", "Y", "Y", "Y", "N")),
impacted_family = c("4", "0", "5", "1", "2", "0", "3", "0", "2", "2"),
month = c(
"Jan-21", "Jan-21", "Feb-21", "Jan-21", "Mar-21", "Mar-21", "Apr-21",
"Oct-20", "Nov-20", "Dec-20"
)
)
self_impact impacted_family month
Y 4 Jan-21
Y 0 Jan-21
Y 5 Feb-21
N 1 Jan-21
N 2 Mar-21
Y 0 Mar-21
Y 3 Apr-21
Y 0 Oct-20
Y 2 Nov-20
N 2 Dec-20
For year 2020 there are 2 self_impact vs 2021 with 5 self impact.
Of these 2 self impact in 2020 one family got infected whereas in 2021 out of 5 self impact 3 family were infected.
Also the number of impacted family member is very high in 2021 vs 2020.
I want to show this three information in stacked bar chart using ggplot with some color option for each year.
Any help is useful, Thanks!


