library(tidyverse)
-- Attaching packages --------------------------------------- tidyverse 1.2.1 --
v ggplot2 2.2.1     v purrr   0.2.4
v tibble  1.3.4     v dplyr   0.7.4
v tidyr   0.7.2     v stringr 1.2.0
v readr   1.1.1     v forcats 0.2.0
-- Conflicts ------------------------------------------ tidyverse_conflicts() --
x dplyr::filter() masks stats::filter()
x dplyr::lag()    masks stats::lag()
library(infer)
mtcars <- as.data.frame(mtcars) %>%
  mutate(cyl = factor(cyl),
          vs = factor(vs),
          am = factor(am),
          gear = factor(gear),
          carb = factor(carb))
mtcars %>%
  specify(am ~ vs, success = "1") %>%
  hypothesize(null = "independence") %>%
  generate(reps = 100, type = "permute") %>%
  calculate(stat = "diff in props", order = c("1", "0"))
mtcars %>%
  specify(mpg ~ am) %>%
  generate(reps = 100, type = "bootstrap") %>%
  calculate(stat = "diff in means", order = c("1", "0")) 
mtcars %>%
  specify(mpg ~ am) %>%
  generate(reps = 100, type = "bootstrap") %>%
  calculate(stat = "diff in means", order = c("1", "0")) %>% 
        ggplot(aes(x = stat)) +
        geom_histogram(bins = 10)

LS0tDQp0aXRsZTogImluZmVyIg0Kb3V0cHV0OiBodG1sX25vdGVib29rDQotLS0NCmBgYHtyfQ0KDQpsaWJyYXJ5KHRpZHl2ZXJzZSkNCg0KYGBgDQoNCmBgYHtyfQ0KbGlicmFyeShpbmZlcikNCmBgYA0KDQoNCmBgYHtyfQ0KbXRjYXJzIDwtIGFzLmRhdGEuZnJhbWUobXRjYXJzKSAlPiUNCiAgbXV0YXRlKGN5bCA9IGZhY3RvcihjeWwpLA0KICAgICAgICAgIHZzID0gZmFjdG9yKHZzKSwNCiAgICAgICAgICBhbSA9IGZhY3RvcihhbSksDQogICAgICAgICAgZ2VhciA9IGZhY3RvcihnZWFyKSwNCiAgICAgICAgICBjYXJiID0gZmFjdG9yKGNhcmIpKQ0KYGBgDQoNCg0KDQpgYGB7cn0NCm10Y2FycyAlPiUNCiAgc3BlY2lmeShhbSB+IHZzLCBzdWNjZXNz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