View source: R/merge_multilevel.R
merge_multilevel | R Documentation |
Merges two data frames with different levels to create a single data frame
merge_multilevel(
dat_l1,
dat_l2 = NULL,
id,
var_agg,
suffix_l = c(".l1", ".l2"),
suffix_m = c("", ".mean"),
agg_func = function(x) mean(x, na.rm = TRUE)
)
dat_l1 |
Level 1 data frame containing data to merge |
dat_l2 |
Level 2 data frame containing data to merge |
id |
String with variable name for matching datasets |
var_agg |
Vector with strings of L1 variables that are aggregated at
Level2 with the |
suffix_l |
A character vector of suffixes for the merged Level 2 columns (default: c('.l1', '.l2')) |
suffix_m |
A character vector of suffixes for the merged aggregated columns (default: c(”, '.mean')) |
agg_func |
The function used in aggregation (default: function(x) mean(x, na.rm = TRUE)) |
Returns a merged data frame
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.