prepare_data | R Documentation |
mutual
functionTakes a tabular object (micro-data or a frequency table) and returns a
data.table
ready for mutual
.
The output
* stores every analytical variable as a factor
;
* holds the weight variable under the unified name fw
(numeric);
* aggregates identical combinations (summing their weights) and drops rows
where fw == 0
.
prepare_data(data, vars, fw = NULL, col.order = NULL)
data |
A tabular object: |
vars |
A vector of column names or indices, or the literal
|
fw |
(optional) Name or index of the frequency-weight column.
Must reference exactly one column. If |
col.order |
(optional) Column(s) used to sort the final table;
must be included in |
A data.table
with classes "mutual.data"
,
"data.frame"
and "data.table"
.
The analytical variables are stored in the attribute "vars"
;
the key is cleared.
md <- prepare_data(
DF_Seg_Chile,
vars = c("csep", "ethnicity", "school", "district"),
fw = "nobs"
)
md <- prepare_data(DF_Seg_Chile, vars = "all_vars")
class(md)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.