0

I need to sort in ascending order the SCF multiply imputed dataset in R by a specific (numeric) variable. Since I'm working with a svydesign object (containing a list of five implicates from the SCF ) in R, it didn't work to use the function sort or order as we usually do with data.frames. Does anybody know how to do this in R?

Thank u for your help!

  • Please share a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Martin Gal May 27 '20 at 19:01
  • could you clarify why you want to sort a multiply-imputed design? not sure if sorting individual implicates screws up the replicate weights in this design http://asdfree.com/survey-of-consumer-finances-scf.html ` – Anthony Damico May 27 '20 at 22:38
  • Hello, Mr. @AnthonyDamico, Thank you for your answer. I need to subset the dataset from 0 to 1% , 1% to 5% , 5 to 10% and 0 to 20% quantiles, but all this households have earnings=0. Kuhn & Rios-Rull (2015) used income as a second dimension for sorting households. So, i need to sort by earnings, then by income, finally i need to subset the sample. – Carolina Moreno Jun 03 '20 at 06:30
  • scf data has households with nonzero earnings..sounds like you might be trying to create a categorical variable rather than sort? perhaps find cutoffs with the `svyquantile` line from the link above and use those thresholds to create a new variable with `scf_design <- update( scf_design , categorical_variable = findInterval( linear_variable , c( cutoff1 , cutoff2 , cutoff3 ) )` – Anthony Damico Jun 03 '20 at 20:42
  • Thank you so much Mr @AnthonyDamico, your answer helped me to solve my problem. Have a nice week-end. – Carolina Moreno Jun 06 '20 at 19:40

0 Answers0