groupedstats (version 0.0.7)

grouped_summary: Function to get descriptive statistics for multiple variables for all grouping variable levels

Description

Function to get descriptive statistics for multiple variables for all grouping variable levels

Usage

grouped_summary(data, grouping.vars, measures = NULL,
  measures.type = "numeric", topcount.long = FALSE)

Arguments

data

Dataframe from which variables need to be taken.

grouping.vars

A list of grouping variables.

measures

List variables for which summary needs to computed. If not specified, all variables of type specified in the argument measures.type will be used to calculate summaries. Don't explicitly set measures.type = NULL in function call, which will produce an error because the function will try to find a column in a dataframe named "NULL".

measures.type

A character indicating whether summary for numeric ("numeric") or factor/character ("factor") variables is expected (Default: measures.type = "numeric"). This function can't be used for both numeric and variables simultaneously.

topcount.long

If measures.type = factor, you can get the top counts in long format for plotting purposes. (Default: topcount.long = FALSE).

Value

Dataframe with descriptive statistics for numeric variables (n, mean, sd, median, min, max)

Examples

Run this code
# NOT RUN {
# another possibility
groupedstats::grouped_summary(
  data = datasets::iris,
  grouping.vars = Species,
  measures = Sepal.Length:Petal.Width,
  measures.type = "numeric"
)

# if you have just one variable per argument, you need not use `c()`
groupedstats::grouped_summary(
  data = datasets::ToothGrowth,
  grouping.vars = supp,
  measures = len,
  measures.type = "numeric"
)
# }

Run the code above in your browser using DataLab