-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #195 from spsanderson/development
Fixes #190
- Loading branch information
Showing
6 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#' Unnest Tidy Bootstrap Tibble | ||
#' | ||
#' @family Bootstrap | ||
#' | ||
#' @author Steven P. Sanderson II, MPH | ||
#' | ||
#' @details This function takes as input the output of the `tidy_bootstrap()` | ||
#' function and returns a two column tibble. The columns are `sim_number` and `y` | ||
#' | ||
#' It looks for an attribute that comes from using `tidy_bootstrap()` so it will | ||
#' not work unless the data comes from that function. | ||
#' | ||
#' @description Unnest the data output from `tidy_bootstrap()`. | ||
#' | ||
#' @param .data The data that is passed from the `tidy_bootstrap()` function. | ||
#' | ||
#' @examples | ||
#' tb <- tidy_bootstrap(.x = mtcars$mpg) | ||
#' bootstrap_unnest_tbl(tb) | ||
#' | ||
#' bootstrap_unnest_tbl(tb) %>% | ||
#' tidy_distribution_summary_tbl(sim_number) | ||
#' | ||
#' @return | ||
#' A tibble | ||
#' | ||
#' @export | ||
#' | ||
|
||
bootstrap_unnest_tbl <- function(.data){ | ||
|
||
# Checks ---- | ||
atb <- attributes(.data) | ||
distribution_family_type <- atb$dist_type | ||
|
||
if (!atb$tibble_type == "tidy_bootstrap_nested"){ | ||
rlang::abort( | ||
message = "You must provide the output from the tidy_bootstrap() function.", | ||
use_cli_format = TRUE | ||
) | ||
} | ||
|
||
# Data ---- | ||
df <- tidyr::unnest(.data, bootstrap_samples) %>% | ||
purrr::set_names("sim_number", "y") | ||
|
||
# Return ---- | ||
attr(df, ".num_sims") <- atb$.num_sims | ||
attr(df, "distribution_family_tpe") <- distribution_family_type | ||
attr(df, "tibble_type") <- "tidy_bootstrap" | ||
attr(df, "dist_with_params") <- "Empirical" | ||
|
||
return(df) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.