describe_stats: Compute descriptive statistics

View source: R/describe_stats.R

describe_statsR Documentation

Compute descriptive statistics

Description

This function provides a range of descriptive statistics that are useful to explore numeric data. If a grouping variable is specified, the descriptive statistics are computed separately for each group.

Usage

describe_stats(data, .cols, .group = NULL)

Arguments

data

A data frame.

.cols

<data-masked> The name/s or column number/s of the numeric variable/s to compute descriptive statistics for.

.group

<data-masked> Optional. The name of the grouping variable. The default is NULL.

Value

A tibble or a tibble grouped by .group containing the following statistics:

  • n Number of valid observations

  • missings Percentage of missings

  • mean Mean

  • sd Standard deviation

  • min Minimum

  • p25 25th percentile

  • median Median

  • p75 75th percentile

  • max Maximum

  • mean_h Harmonic mean

  • skewness Skewness

  • kurtosis Kurtosis

Examples

# -- Simple descriptive statistics across all observations

# compute descriptive statistics for students' mathematics achievement

# using the name of the variable
describe_stats(studach, .cols = math)

# using the position by column number
describe_stats(studach, .cols = 11)

# compute descriptive statistics for all numeric variables
describe_stats(studach, .cols = where(is.numeric))

# -- Descriptive statistics by school type or gender
describe_stats(studach, .cols = math, .group = ts_name)
describe_stats(studach, .cols = math, .group = gender)


sophiestallasch/multides documentation built on Oct. 20, 2024, 5:14 a.m.