-2

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?

alt text

KOULY
  • 1
  • Please make a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) or [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) with sample input that can be used to test and verify possible solutions. – Martin Gal Oct 05 '21 at 21:16

1 Answers1

-2
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")
KOULY
  • 1