The goal of strapgod is to create virtual groups on top of a tibble or grouped_df as a way of resampling the original data frame. You can then efficiently perform various dplyr operations on this resampled_df, like: summarise(), do(), group_map(), and more, to easily compute bootstrapped and resampled statistics.


You can install the released version of strapgod from CRAN with:


Install the development version from GitHub with:

Learning about strapgod

If you aren’t already on the pkgdown site, I would encourage starting there. From there, you will be able to click on these two vignettes to learn about working with resampled tibbles.


Create resampled data frames with bootstrapify() or samplify(). Notice how we grouped by the virtual column, .bootstrap and there are still only 150 rows even though we bootstrapped this dataset 10 times.

You can feed a resampled_df into summarise() or group_modify() to perform efficient bootstrapped computations.

The original data can be grouped as well, and the bootstraps will be created for each group.

Plotting bootstrapped results

A fun example of using strapgod is to create bootstrapped visualizations quickly and easily for hypothetical outcome plots.


# without bootstrap
mtcars %>%
  ggplot(aes(hp, mpg)) + 
  geom_smooth(se = FALSE) +
  ylim(y = c(0, 40))

# with bootstrap
mtcars %>%
  bootstrapify(10) %>%
  collect() %>%
  ggplot(aes(hp, mpg, group = .bootstrap)) + 
  geom_smooth(se = FALSE) +
  ylim(y = c(0, 40))

In the wild

  • Claus Wilke has used strapgod to power some pieces of his ungeviz package for visualizing uncertainty.

  • You can watch Claus’s rstudio::conf 2019 talk to see ungeviz and strapgod in action.