You're confused about >
and R's recycling behavior. When quantile
returns more than 1 value (as in the last two examples) it recycles those vectors to be the same length as x
in order to make the vectorized comparison via >
.
So, in the last two examples, it repeats the 2 or 3 values from quantile
over and over again until the resulting vector is the same length as x
and them compares them element-wise with >
.
Edit
Maybe my explanation wasn't clear enough. In the last line of your edit, x > quantile( x, c( 0.1, 0.2 ) )
R is comparing the first element of x
with the 0.1 quantile, the second element of x
with the 0.2 quantile, the third element of x
with the 0.1 quantile, the 4th element of x
with the 0.2 quantile, and so on. Got it? :)