calc_density {APCtools}R Documentation

Internal helper to calculate the (group-specific) density of a variable

Description

Internal helper function that is called in plot_density to calculate the density of a metric variable. If plot_density is called from within plot_densityMatrix (i.e., when some of the columns c("age_group","period_group","cohort_group") are part of the dataset, the density is computed individually for all respective APC groups.

Usage

calc_density(dat, y_var, weights_var = NULL, ...)

Arguments

dat

Dataset with columns period and age and the main variable specified through argument y_var.

y_var

Character name of the main variable to be plotted.

weights_var

Optional character name of a weights variable used to project the results in the sample to some population.

...

Additional arguments passed to density.

Value

Dataset with the calculated densities.


[Package APCtools version 1.0.4 Index]