I've been working with a tibble I created and I was wanting to create a ridge plot with ggplot2.
I have a list of regions, GDP and Infant Mortality. I was hoping to compare each region as a coloured ridge showing GDP as x and Infant Mortality as y.
This is as far as I've gotten but it's not working (probably because I don't think I'm quite understanding each part).
library(ggplot2)
install.packages("ggridges")
library(ggridges)
as.tibble(Region_Compare)
colnames(Region_Compare)
ggplot(Region_Compare, aes(x = `GDP`, y = `Infant mortality`, fill = cut)) +
geom_density_ridges() +
theme_ridges() +
theme()
I get the following error:
Error: Aesthetics must be valid data columns. Problematic aesthetic(s): fill = cut. Did you mistype the name of a data column or forget to add after_stat()?
Could someone please help me understand where I'm going wrong and where what I might need to add?
I was hoping to do something like the picture attached. With x showing regions labelled and y showing Infant mortality, with the peaks or density showing GDP. Is that possibly or should I be looking at something else.
Wishful thinking pic: