geom_density_ridges requires the following missing aesthetics: y
I have also noticed , if y is a factor this error will not pop up. try this :)
ggplot(graphing_dataframe,
aes(x = id, y=as.factor(rating))) +
geom_density_ridges()
This question seems to be at the top of the list when googling this error message, so I thought I'd chime in: the other reason you can get this error is if you have your x
and y
switched:
For instance, with the above data (using id
instead), this works:
ggplot(graphing_dataframe,
aes(x = rating, y = id)) +
geom_density_ridges()
While this throws the error:
ggplot(graphing_dataframe,
aes(x = id, y=rating)) +
geom_density_ridges()
Seems as if the error message is a bit misleading, according to the documentation you need to add a group aesthetic for numerical variables:
The grouping aesthetic does not need to be provided if a categorical variable is mapped onto the y axis, but it does need to be provided if the variable is numerical.
so adding group = week
to ggplot(aes(…))
ought to do the trick. (Just had the same issue myself.)