Learn R Programming

grafify (version 5.0.0)

table_summary: Get numeric summary grouped by factors

Description

This is a wrapper around aggregate function in base R to obtain mean, median, standard deviation and count for quantitative variable(s) grouped by one or more factors. More than one column containing of quantitative variables can be passed on, and summaries for each is provided with column names with a ..

Usage

table_summary(data, Ycol, ByGroup)

Value

this function takes in a data.frame or tibble and returns a data.frame or tibble.

Arguments

data

name of the data table.

Ycol

name of one column (in quotes) or a vector of column names (e.g., c("Y1", "Y2")) containing the numerical variable to be summarised.

ByGroup

name of one column (in quotes) or a vector of column names (e.g., c("A", "B")) containing the grouping factors

Examples

Run this code
table_summary(Ycol = "cty",
ByGroup = c("fl", "drv"),
data = mpg)

Run the code above in your browser using DataLab