describe_by: Basic summary statistics by group

View source: R/describe_by.R

describe_byR Documentation

Basic summary statistics by group

Description

This is a re-implementation of the psych::describeBy function using the dplyr package for creating the resulting table. The goal is for this function to be a drop-in replacement, however the results are always returned as a data.frame consistent with the mat = TRUE parameter setting.

Usage

describe_by(x, group = NULL, type = 3, trim = 0.1, na.rm = TRUE, mat, ...)

Arguments

x

a numeric vector to summarize.

group

a grouping vector.

type

type of skewness, see psych::skew for details.

trim

the fraction (0 to 0.5) of observations to be trimmed from each end of x before the mean is computed. Values of trim outside that range are taken as the nearest endpoint.

na.rm

a logical evaluating to TRUE or FALSE indicating whether NA values should be stripped before the computation proceeds.

mat

not used, provided to provide direct compatability with psych::describeBy.

...

not currently used. Included to ensure compatibility.

Details

The psych package is an incredibly useful package but some of the dependencies are problematic for deploying Shiny applications using shinylive. Since this package only uses the describeBy function from the psych package, we re-implemented it in order to remove the dependency on the psych package.

Value

a data.frame with the summary statistic.

Examples

data(mtcars)
describe_by(mtcars$mpg, group = mtcars$cyl)

jbryer/VisualStats documentation built on Feb. 27, 2025, 6:19 p.m.