q <- quantile(faithful$eruptions)
> q
0% 25% 50% 75% 100%
1.60000 2.16275 4.00000 4.45425 5.10000
I get the following result, the dataset is provided in R.
head(faithful)
eruptions waiting
1 3.600 79
2 1.800 54
3 3.333 74
4 2.283 62
5 4.533 85
6 2.883 55
I want a dataframe containing the data and an additional column for pointing out the quantile to which each observations belong. For example the final dataset should look like
eruptions waiting Quartile
1 3.600 79 Q1
2 1.800 54 Q2
3 3.333 74
4 2.283 62
5 4.533 85
6 2.883 55
How can this be done?