prep_df_summ.Rd
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)
A dataframe to be summarized
A character vector specifying the columns to be grouped by
A character vector specifying the column to be summarized
A summarized dataframe
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")