-1

please a have a dataframe called wine with variables among which is the variable Spice of integer type.

I will like to split this variable(Spice) using the quantile() function into 3 classes of identical values

NB :USING the quantile() function please

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • 1
    When asking for help, you should provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data and the desired output for that input. What does "3 classes of identical values" mean exactly? And why would you require the `quantile()` function specifically? – MrFlick Jul 06 '17 at 18:30

1 Answers1

1

Like MrFlick said, your question is ill formed. Do you want to split what? Spice or wine? If Spice is integer the quantiles will generally not split it in groups of equal sizes. Anyway here is code to do something similar to what you've tried to ask.

set.seed(4124)
wine <- data.frame(Spice = sample(5, 20, TRUE))
qq <- quantile(wine$Spice, probs = seq(0, 1, 1/3))
split(wine, findInterval(wine$Spice, qq, all.inside = TRUE))
Rui Barradas
  • 70,273
  • 8
  • 34
  • 66