library(tidyverse)
[37m-- [1mAttaching packages[22m --------------------------------------- tidyverse 1.2.1 --[39m
[37m[32mv[37m [34mggplot2[37m 2.2.1 [32mv[37m [34mpurrr [37m 0.2.4
[32mv[37m [34mtibble [37m 1.3.4 [32mv[37m [34mdplyr [37m 0.7.4
[32mv[37m [34mtidyr [37m 0.7.2 [32mv[37m [34mstringr[37m 1.2.0
[32mv[37m [34mreadr [37m 1.1.1 [32mv[37m [34mforcats[37m 0.2.0[39m
[37m-- [1mConflicts[22m ------------------------------------------ tidyverse_conflicts() --
[31mx[37m [34mdplyr[37m::[32mfilter()[37m masks [34mstats[37m::filter()
[31mx[37m [34mdplyr[37m::[32mlag()[37m masks [34mstats[37m::lag()[39m
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)

LS0tDQp0aXRsZTogImluZmVyIg0Kb3V0cHV0OiBodG1sX25vdGVib29rDQotLS0NCmBgYHtyfQ0KDQpsaWJyYXJ5KHRpZHl2ZXJzZSkNCg0KYGBgDQoNCmBgYHtyfQ0KbGlicmFyeShpbmZlcikNCmBgYA0KDQoNCmBgYHtyfQ0KbXRjYXJzIDwtIGFzLmRhdGEuZnJhbWUobXRjYXJzKSAlPiUNCiAgbXV0YXRlKGN5bCA9IGZhY3RvcihjeWwpLA0KICAgICAgICAgIHZzID0gZmFjdG9yKHZzKSwNCiAgICAgICAgICBhbSA9IGZhY3RvcihhbS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