Description Usage Arguments Details Value Examples
serpentine
sorts data in a serpentine fashion (alternating between
ascending and descending orders) for all variables specified.
mixed_serpentine
sorts the data with ascending or descending sorts
for every variable specified except the last, which is serpentine sorted.
1 2 3 | serpentine(data = NULL, ...)
mixed_serpentine(data = NULL, ...)
|
data |
is the data.frame to be sorted |
... |
are the variables to serpentine sort, in the given order. In
|
This is helpful in complex sampling designs with implicit stratification, as it reduces the variation in the stratified outcome for adjacent sampled units and thus reduces the overall sampling error. Serpentine sorts are commonly used in NCES surveys.
A data.frame with equal size as the original data, but sorted differently.
1 2 3 4 5 6 7 8 9 | # All variables except first are serpentine sorted
serpentine(data = mtcars, cyl, mpg)
serpentine(data = mtcars, cyl, vs, mpg)
# cyl, and vs are ascending sorted while mpg is serpentine sorted
mixed_serpentine(mtcars, cyl, vs, mpg)
# cyl is ascending, vs is descending, and mpg is serpentine sorted
mixed_serpentine(mtcars, cyl, desc(vs), mpg)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.