Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

desc_statby

Descriptive statistics by groups


Description

Computes descriptive statistics by groups for a measure variable.

Usage

desc_statby(data, measure.var, grps, ci = 0.95)

Arguments

data

a data frame.

measure.var

the name of a column containing the variable to be summarized.

grps

a character vector containing grouping variables; e.g.: grps = c("grp1", "grp2")

ci

the percent range of the confidence interval (default is 0.95).

Value

A data frame containing descriptive statistics, such as:

  • length: the number of elements in each group

  • min: minimum

  • max: maximum

  • median: median

  • mean: mean

  • iqr: interquartile range

  • mad: median absolute deviation (see ?MAD)

  • sd: standard deviation of the mean

  • se: standard error of the mean

  • ci: confidence interval of the mean

  • range: the range = max - min

  • cv: coefficient of variation, sd/mean

  • var: variance, sd^2

Examples

# Load data
data("ToothGrowth")

# Descriptive statistics
res <- desc_statby(ToothGrowth, measure.var = "len",
   grps = c("dose", "supp"))
head(res[, 1:10])

ggpubr

'ggplot2' Based Publication Ready Plots

v0.4.0
GPL-2
Authors
Alboukadel Kassambara [aut, cre]
Initial release
2020-06-27

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.