merge_multilevel: Merge Multiple Level Data

View source: R/merge_multilevel.R

merge_multilevelR Documentation

Merge Multiple Level Data

Description

Merges two data frames with different levels to create a single data frame

Usage

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)
)

Arguments

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 agg_func function.

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))

Value

Returns a merged data frame


jazznbass/wmisc documentation built on Oct. 29, 2024, 5:42 p.m.