Learn R Programming

vvshiny (version 0.1.1)

prep_df_summ: Prepare summarized dataframe

Description

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.

Usage

prep_df_summ(df, variables, y)

Value

A summarized dataframe

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

Examples

Run this code
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")

Run the code above in your browser using DataLab