calculate: Calculate summary statistics

Description Usage Arguments Value Examples

View source: R/calculate.R

Description

Calculate summary statistics

Usage

1
2
3
calculate(x, stat = c("mean", "median", "sum", "sd", "prop", "count",
  "diff in means", "diff in medians", "diff in props", "Chisq", "F",
  "slope", "correlation", "t", "z"), order = NULL, ...)

Arguments

x

The output from generate() for computation-based inference or the output from hypothesize() piped in to here for theory-based inference.

stat

A string giving the type of the statistic to calculate. Current options include "mean", "median", "sum", "sd", "prop", "count", "diff in means", "diff in medians", "diff in props", "Chisq", "F", "t", "z", "slope", and "correlation".

order

A string vector of specifying the order in which the levels of the explanatory variable should be ordered for subtraction, where order = c("first", "second") means ("first" - "second") Needed for inference on difference in means, medians, or proportions and t and z statistics.

...

To pass options like na.rm = TRUE into functions like mean(), sd(), etc.

Value

A tibble containing a stat column of calculated statistics.

Examples

1
2
3
4
5
6
7
# Permutation test for two binary variables
mtcars %>%
  dplyr::mutate(am = factor(am), vs = factor(vs)) %>%
  specify(am ~ vs, success = "1") %>%
  hypothesize(null = "independence") %>%
  generate(reps = 100, type = "permute") %>%
  calculate(stat = "diff in props", order = c("1", "0"))

andrewpbray/infer documentation built on Aug. 29, 2019, 5:57 a.m.