prepare_data | R Documentation |
mutual
functionReceives the data that is later used in the mutual
function.
Generates a data.table
with the entry variables.
prepare_data(data, vars, fw = NULL, col.order = NULL)
data |
A tabular format object ( |
vars |
A vector of variable names or vector of columns numbers contained in |
fw |
Variable name or column number contained in |
col.order |
A variable name or vector of variables names contained in |
Returns a data.table
of class "data.table" "data.frame" "mutual.data".
# Using some variable names in 'data' with explicit 'fw'.
my_data <- prepare_data(data = DF_Seg_Chile, vars = c("csep", "ethnicity", "school", "district"),
fw = "nobs")
# Using some column numbers in 'data' and explicit 'fw' as another column number.
my_data <- prepare_data(data = DF_Seg_Chile, vars = c(4, 5, 2, 3), fw = 11)
# Using all variables of 'data' with explicit 'fw'.
my_data <- prepare_data(data = DF_Seg_Chile, vars = "all_vars", fw = "nobs")
# Using some variable names in 'data' and 'fw' does not exist (in this case, the new 'fw' will
# be equal to 1 for all variable combinations as 'data' already has a frequency weights variable)
my_data <- prepare_data(data = DF_Seg_Chile, vars = c("csep", "ethnicity", "school", "district"))
# Using the 'col.order' option to sort data according to the 'csep' column.
my_data <- prepare_data(data = DF_Seg_Chile, vars = c("csep", "ethnicity", "school", "district"),
fw = "nobs", col.order = "csep")
# The class of the resulting object in all cases must be "data.table", "data.frame" and
# "mutual.data".
class(my_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.