R Decile percentage plotting
I have a data frame from a home income poll that looks like this:
ID Income Expense
001 2389.9 1400.5
003 5499.3 2309.2
.. .. ..
*this is an example, the actual one has over 5k observations
I would like to be able to:
- Plot the decile distribution by income only.
- Create a variable which assigns the tenth of the distribution by income only each Home is in.
I already tried this but it is not what I want, I'd like to know the percentage of homes in each tenth:
Deciles<-quantile(DF$Income, prob = seq(0, 1, length = 11), type = 5) Deciles
0% 10% 20% 30% 40% 50% 60%
231.89 9024.48 13308.24 16945.15 21071.38 25661.58 31607.07
70% 80% 90% 100%
40360.98 52927.98 77926.47 1634433.60
- For the second part I'm looking to get something like this:
ID Income Expense Decile
001 2389.9 1400.5 3
003 5499.3 2309.2 5
009 2245.0 1789.2 3
.. .. .. ..
Thanks!