Learn R Programming

infer (version 0.2.0)

calculate: Calculate summary statistics

Description

Calculate summary statistics

Usage

calculate(x, stat, 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", "sd", "prop", "diff in means", "diff in medians", "diff in props", "Chisq", "F", "t", "z", and "slope".

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.

...

to pass options like na.rm = TRUE into functions like mean, sd, etc.

Value

A tibble containing a stat column of calculated statistics

Examples

Run this code
# NOT RUN {
# 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"))
# }

Run the code above in your browser using DataLab