Here is my reproducible data:
library("ggplot2")
library("ggplot2movies")
library("quantreg")
set.seed(2154)
msamp <- movies[sample(nrow(movies), 1000), ]
I am trying to become acquainted with stat_quantile but the example from the documentation raises a couple of questions.
mggp <- ggplot(data=msamp, mapping=aes(x=year, y=rating)) +
geom_point() +
stat_quantile(formula=y~x, quantiles=c(0, 0.25, 0.50, 0.75, 1)) +
theme_classic(base_size = 12) +
ylim(c(0,10))
mggp
To my understanding quantiles split the data into parts that are smaller than the defined cut-off values, correct? If I define quantiles like in the following code I get five lines. Why? What do they represent?
It seems that the quantiles are calculated based on the dependent variable on the y-axis (rating). Is it possible to reverse this? I mean to split the data based on quantiles in 'year'?