diff --git a/NEWS.md b/NEWS.md index 2e678b33..0a0e5147 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ * Started moving error messages to cli (#499, #502). +* Fixed example for `nested_cv()` (@seb09, #520). + ## Bug fixes * `vfold_cv()` now utilizes the `breaks` argument correctly for repeated cross-validation (@ZWael, #471). diff --git a/R/nest.R b/R/nest.R index d3c6b080..d2d3427e 100644 --- a/R/nest.R +++ b/R/nest.R @@ -34,18 +34,18 @@ #' inside = vfold_cv(v = 3) #' ) #' -#' first_outer_split <- bad_idea$splits[[1]] -#' outer_analysis <- as.data.frame(first_outer_split) -#' sum(grepl("Volvo 142E", rownames(outer_analysis))) +#' first_outer_split <- get_rsplit(bad_idea, 1) +#' outer_analysis <- analysis(first_outer_split) +#' sum(grepl("Camaro Z28", rownames(outer_analysis))) #' #' ## For the 3-fold CV used inside of each bootstrap, how are the replicated -#' ## `Volvo 142E` data partitioned? -#' first_inner_split <- bad_idea$inner_resamples[[1]]$splits[[1]] -#' inner_analysis <- as.data.frame(first_inner_split) -#' inner_assess <- as.data.frame(first_inner_split, data = "assessment") +#' ## `Camaro Z28` data partitioned? +#' first_inner_split <- get_rsplit(bad_idea$inner_resamples[[1]], 1) +#' inner_analysis <- analysis(first_inner_split) +#' inner_assess <- assessment(first_inner_split) #' -#' sum(grepl("Volvo 142E", rownames(inner_analysis))) -#' sum(grepl("Volvo 142E", rownames(inner_assess))) +#' sum(grepl("Camaro Z28", rownames(inner_analysis))) +#' sum(grepl("Camaro Z28", rownames(inner_assess))) #' @export nested_cv <- function(data, outside, inside) { cl <- match.call() diff --git a/man/nested_cv.Rd b/man/nested_cv.Rd index 826a9c47..cdb19761 100644 --- a/man/nested_cv.Rd +++ b/man/nested_cv.Rd @@ -48,16 +48,16 @@ bad_idea <- nested_cv(mtcars, inside = vfold_cv(v = 3) ) -first_outer_split <- bad_idea$splits[[1]] -outer_analysis <- as.data.frame(first_outer_split) -sum(grepl("Volvo 142E", rownames(outer_analysis))) +first_outer_split <- get_rsplit(bad_idea, 1) +outer_analysis <- analysis(first_outer_split) +sum(grepl("Camaro Z28", rownames(outer_analysis))) ## For the 3-fold CV used inside of each bootstrap, how are the replicated -## `Volvo 142E` data partitioned? -first_inner_split <- bad_idea$inner_resamples[[1]]$splits[[1]] -inner_analysis <- as.data.frame(first_inner_split) -inner_assess <- as.data.frame(first_inner_split, data = "assessment") +## `Camaro Z28` data partitioned? +first_inner_split <- get_rsplit(bad_idea$inner_resamples[[1]], 1) +inner_analysis <- analysis(first_inner_split) +inner_assess <- assessment(first_inner_split) -sum(grepl("Volvo 142E", rownames(inner_analysis))) -sum(grepl("Volvo 142E", rownames(inner_assess))) +sum(grepl("Camaro Z28", rownames(inner_analysis))) +sum(grepl("Camaro Z28", rownames(inner_assess))) }