I do have a data frame with different categorical and numerical columns with the following schema:
Country | Year | Conflict | Epidemics | Famine | Natural Disaster | Other
How to plot such a graph without redoing the data.frame?
I do have a data frame with different categorical and numerical columns with the following schema:
Country | Year | Conflict | Epidemics | Famine | Natural Disaster | Other
How to plot such a graph without redoing the data.frame?
library(tidyr)
library(dplyr)
library(ggplot2)
data %>% pivot_longer(cols = Conf.and.Terr:Other, names_to = "var", values_to = "val") %>%
ggplot(aes(x = Year, y = val, fill = var))+
geom_bar(position = "fill", width = 0.5, stat = "identity")