I need help creating a way of sorting a column in R so that I can plot household rank by consumption per capita. I have a column with all of the consumption per capita which will go on the y-axis and then need to put their "rank" on the x-axis from [0,1] separated by .1. I have 4200 consumption per capita data points so everyone from [1,420] should go in the first .1 percentile and so on.
Asked
Active
Viewed 70 times
-3
-
4Please make this question *reproducible*. This includes sample code (including listing non-base R packages), sample data (e.g., `dput(head(x))`), and expected output. Refs: https://stackoverflow.com/questions/5963269, https://stackoverflow.com/help/mcve, and https://stackoverflow.com/tags/r/info. – r2evans Sep 26 '18 at 23:53
1 Answers
2
rank<-dplyr::ntile(cpc,1000)
(cpc is your consumption per capita vector). This will separate your vector into 1000 buckets of 0.1% each.

iod
- 7,412
- 2
- 17
- 36