descrips: Pipe-friendly descriptive stats

Description Usage Arguments Value Examples

View source: R/descrips.R

Description

Generate any set of descriptive statistics through the pipeline and return a tidy data frame. The function works with any number of variables, as well as with group_by.

Usage

1
2
3
4
5
6
descrips(
  data,
  ...,
  .funs = dplyr::funs(n(), min(., na.rm = TRUE), max(., na.rm = TRUE), mean(., na.rm =
    TRUE), sd(., na.rm = TRUE))
)

Arguments

data

The data frame that includes the variables to compute descriptive statistics on.

...

The set of variables to compute descriptive statistics on.

.funs

The functions to use in the descriptive statistics. Uses the funs function. Defaults to the number of observations, min, max, mean, and standard deviation.

Value

A tidy data frame with the requested descriptive statistics for the requested variables

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(dplyr)
library(magrittr)
storms %>%
  descrips(wind, pressure)

storms %>%
  group_by(year) %>%
  descrips(wind, pressure)

storms %>%
  group_by(year) %>%
  descrips(wind, pressure, .funs = funs(median, n()))

datalorax/sundry documentation built on April 11, 2021, 1:50 p.m.