vars_consist {esmtools} | R Documentation |
Create Unique Values Dataframe
Description
This function takes a dataframe, a group variable, and a vector of variables. It creates a new dataframe that contains unique values for each variable within each group modality.
Only one group variable should be used, otherwise, an error will be thrown.
The resulting dataframe has the group variable as the first column and each variable's unique values as subsequent columns.
The merge_val
function is applied to merge the unique values within each group.
Usage
vars_consist(.df, group, vars, max_length = 4)
Arguments
.df |
A dataframe containing the data. |
group |
The name of the group variable. |
vars |
A vector of variable names to consider. |
max_length |
The maximum length of the merged values. If the length of the merged values exceeds this value, the values are truncated and an ellipsis is added at the end. Default is 4. |
Value
A dataframe with unique values for each variable within each group modality.
Examples
vars_consist(esmdata_sim, group = "id", vars = c("age", "cond_dyad"))