I'm interested in creating a dummy value in R to identify which income quintile a household is in using PUMS data. However, I'm not sure what the code should look like. I'm guessing that I need to get the number of households at each income - so weighting the households and grouping them by income. Then, I have to calculate the quintile breakdown, and create a (1,2,3...) dummy variable to use in further analysis.
But I'm somewhat at a loss as to what that might look like - in particular, whether or not there is a quintile calculation function for R.
Anybody have a sense of what that code might look like / where to start looking?
Both the `reldist` and `Hmisc` packages have a function called `wtd.quantile()`. `reldist::wtd.quantile()` is simpler (and will accept a vector of quantiles to calculate, though the documentation suggests…
I would try `survey::svyquantile()`. The vignette for `library(ipumsr)` (which is what I hope you use) gives some indication as to what to do with the `survey::svydesign` specifications.
We also have some tools in tidycensus that help getting PUMS data and converting them into survey objects to analyze.
Neat. I tend to stick to the "base R" / original survey syntax top have the full control of everything, but it looks like I am missing out ;)