Reputation: 11
For example, I am trying to make a variable that will assign 1, 2, 3,4.
1 <25th percentile
2 >= 25th percentile
upto 50th percentile
similarly, 3 and 4. and so on
Could anyone give me some clues in how I would complete this?
Upvotes: 1
Views: 27
Reputation: 887173
We can specify the breaks
as quantile
in cut
and then convert the factor
output to integer
with as.integer
as.integer(cut(v1, breaks = quantile(v1)))
Upvotes: 0