Skip to content

Commit

Permalink
add an example
Browse files Browse the repository at this point in the history
  • Loading branch information
‘topepo’ committed Jan 22, 2024
1 parent 8a387a2 commit 4efdb65
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ Config/Needs/website:
tidyverse/tidytemplate
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.0
Config/testthat/edition: 3
28 changes: 27 additions & 1 deletion R/bootci.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,13 @@ pctl_single <- function(stats, alpha = 0.05) {
#' Application_. Cambridge: Cambridge University Press.
#' doi:10.1017/CBO9780511802843
#'
#' @examplesIf rlang::is_installed("broom")
#' @examplesIf rlang::is_installed("broom") & rlang::is_installed("modeldata")
#' \donttest{
#' library(broom)
#' library(dplyr)
#' library(purrr)
#' library(tibble)
#' library(tidyr)
#'
#' # ------------------------------------------------------------------------------
#'
Expand Down Expand Up @@ -256,6 +257,31 @@ pctl_single <- function(stats, alpha = 0.05) {
#' bootstraps(Sacramento, 1000, apparent = TRUE) %>%
#' mutate(correlations = map(splits, rank_corr)) %>%
#' int_pctl(correlations)
#'
#' # ------------------------------------------------------------------------------
#' # An example of computing the interval for each value of a custom grouping
#' # factor (type of house in this example)
#'
#' # Get regression estimates for each house type
#' lm_est <- function(split, ...) {
#' analysis(split) %>%
#' tidyr::nest(.by = c(type)) %>%
#' # Compute regression estimates for each house type
#' mutate(
#' betas = purrr::map(data, ~ lm(log10(price) ~ sqft, data = .x) %>% tidy())
#' ) %>%
#' # Convert the column name to begin with a period
#' rename(.type = type) %>%
#' select(.type, betas) %>%
#' unnest(cols = betas)
#' }
#'
#' set.seed(52156)
#' house_rs <-
#' bootstraps(Sacramento, 1000, apparent = TRUE) %>%
#' mutate(results = map(splits, lm_est))
#'
#' int_pctl(house_rs, results)
#' }
#' @export
int_pctl <- function(.data, ...) {
Expand Down
28 changes: 27 additions & 1 deletion man/int_pctl.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4efdb65

Please sign in to comment.