bootstrapify: Create a bootstrapped tibble

Description Usage Arguments Details Value See Also Examples

View source: R/bootstrapify.R

Description

bootstrapify() creates a bootstrapped tibble with virtual groups.

Usage

1
bootstrapify(data, times, ..., key = ".bootstrap")

Arguments

data

A tbl.

times

A single integer specifying the number of resamples. If the tibble is grouped, this is the number of resamples per group.

...

Not used.

key

A single character specifying the name of the virtual group that is added.

Details

The following functions have special / interesting behavior when used with a resampled_df:

Value

A resampled_df with an extra group specified by the key.

See Also

collect.resampled_df()

Other virtual samplers: samplify

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
library(dplyr)
library(broom)

bootstrapify(iris, 5)

iris %>%
  bootstrapify(5) %>%
  summarise(per_strap_mean = mean(Petal.Width))

iris %>%
  group_by(Species) %>%
  bootstrapify(5) %>%
  summarise(per_strap_species_mean = mean(Petal.Width))

iris %>%
  bootstrapify(5) %>%
  do(tidy(lm(Sepal.Width ~ Sepal.Length + Species, data = .)))

# Alternatively, use the newer group_modify()
iris %>%
  bootstrapify(5) %>%
  group_modify(~tidy(lm(Sepal.Width ~ Sepal.Length + Species, data = .x)))

# Alter the name of the group with `key`
# Materialize them with collect()
straps <- bootstrapify(iris, 5, key = ".straps")
collect(straps)

DavisVaughan/strapgod documentation built on Jan. 25, 2020, 8:01 a.m.