add.random.fraction.to.cols | R Documentation |
Add a random number to a specified column, "my_col", then sort rows based on my_col, with the
random fraction used to break any ties. This is a helper function used in dbRake
within the raking algorithm functions (allowNegsnoMargin
, noNegsnoMargin
,
and noNegsneedMargin
), when there are more than two row groups (e.g., Regions, 5-year
Age Groups, Ages, more than two sexes (when Stats Can adds more than Male and Female)).
add.random.fraction.to.cols(df, my_col)
df |
a dataframe (e.g., VarRow (e.g., for "LHA"), whichever columns being raked over, "Min") |
my_col |
a column in df (i.e., "Min" which is the minimum value for each row). This is the column that the rows need to be sorted by. That is, the df needs to be sorted with the VarRow with the smallest minimum value to the one with the largest minimum value, in preparation for raking. |
original dataframe without original my_col, but with a new sort_rows column with the order needed to sort rows
The overall raking function: dbRake
()
Other raking helpers:
adjustSex()
,
allowNegsnoMargin()
,
calc.cols()
,
multiRake()
,
noNegsneedMargin()
,
noNegsnoMargin()
,
prep.prorate.col()
,
prorate.col()
,
prorate.row()
,
prorate()
,
read.inputs()
,
real.to.int()
,
rename.age.grps()
,
rounded()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.