Calculate a summary statistic (mean, median, vvconverter::mode, min, max etc.) by group and use it to fill missing values in a column. Primarily for use in fill_with_agg_by_group().

fill_col_with_agg_by_group(df, group, col, statistic)

Arguments

df

tibble to use

group

string or vector of strings: columns to group by

col

string: column to impute

statistic

function: summary statistic to use (mean, median, min etc.). For now requires a function with na.rm argument

Value

a filled vector