weight2rows: Expand a weighted data frame to an equivalent unweighted
Description
Present since v1.0.0.
Argument rows.out available since v1.3.0;
rows.out < 1 supported since v 1.4.0.
Argument discard_weight.var available since v1.3.0.
A data.table. Will be converted to one if possible.
weight.var
Variable in DT to be used as weights.
rows.out
If not NULL (the default) specifies the number of rows in the result;
otherwise the number of rows will be sum(DT[[weight.var]]).
(Due to rounding, this figures are inexact.)
Since v1.4.0, if 0 < rows.out < 1 then taken to be a sample of
the unweighted table. (So rows.out = 0.1 would give a 10% sample.)
discard_weight.var
If FALSE, the default, weight.var
in DT will be 1 for each row in the result or a new weight
if rows.out is given. Otherwise, TRUE drops the column entirely.
Value
DT but with the number of rows expanded to sum(DT[[weight.var]]) to reflect the weighting.