This function prepares a summarized dataframe based on provided variables and a y-variable. The function groups the dataframe by the provided variables, summarizes the y-variable, and counts the number of observations per group.

prep_df_summ(df, variables, y)

Arguments

df

A dataframe to be summarized

variables

A character vector specifying the columns to be grouped by

y

A character vector specifying the column to be summarized

Value

A summarized dataframe

Examples

df <- data.frame(
id = c(1, 1, 2, 2),
group = c("A", "A", "B", "B"),
value = c(2, 4, 6, 8)
)
df_summ <- prep_df_summ(df, c("id", "group"), "value")