-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Milestone
Description
Based on the fact that this being caused at the call to base::sample.int(), I suspect that it's attempting to absorb .data$replace (if present) before the actual replace argument in slice_sample.
Didn't see anyone with this issue on StackOverflow so I'm submitting here for review.
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(reprex)
(slice_sample(tibble(x = 1:10), prop = 0.25))
#> # A tibble: 2 × 1
#> x
#> <int>
#> 1 10
#> 2 6
(slice_sample(tibble(replace = 1:10), prop = 0.25))
#> Error in `slice_sample()`:
#> ! Can't compute indices.
#> Caused by error in `sample.int()`:
#> ! invalid 'replace' argument
#> Backtrace:
#> ▆
#> 1. ├─dplyr::slice_sample(tibble(replace = 1:10), prop = 0.25)
#> 2. ├─dplyr:::slice_sample.data.frame(tibble(replace = 1:10), prop = 0.25)
#> 3. │ ├─dplyr::slice(...)
#> 4. │ └─dplyr:::slice.data.frame(...)
#> 5. │ └─dplyr:::slice_rows(.data, dots, by)
#> 6. │ └─dplyr:::slice_eval(mask, dots, error_call = error_call, user_env = user_env)
#> 7. │ ├─base::withCallingHandlers(...)
#> 8. │ └─mask$eval_all(quo(impl(!!!dots)))
#> 9. ├─dplyr (local) impl(...)
#> 10. │ └─dplyr:::...elt2(i)
#> 11. │ └─rlang::eval_bare(sym(paste0("..", i)), frame)
#> 12. ├─rlang (local) local(...)
#> 13. ├─base::local(...)
#> 14. │ └─base::eval.parent(substitute(eval(quote(expr), envir)))
#> 15. │ └─base::eval(expr, p)
#> 16. │ └─base::eval(expr, p)
#> 17. │ └─base::eval(...)
#> 18. │ └─base::eval(...)
#> 19. │ └─dplyr:::sample_int(n, size(n), replace = replace, wt = weight_by)
#> 20. │ └─base::sample.int(n, size, prob = wt, replace = replace)
#> 21. └─base::.handleSimpleError(...)
#> 22. └─dplyr (local) h(simpleError(msg, call))
#> 23. └─rlang::abort(bullets, call = error_call, parent = cnd)Created on 2023-02-14 with reprex v2.0.2
Session info
sessionInfo()
#> R version 4.2.2 (2022-10-31 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19044)
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=English_United States.utf8
#> [2] LC_CTYPE=English_United States.utf8
#> [3] LC_MONETARY=English_United States.utf8
#> [4] LC_NUMERIC=C
#> [5] LC_TIME=English_United States.utf8
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] reprex_2.0.2 dplyr_1.1.0
#>
#> loaded via a namespace (and not attached):
#> [1] fansi_1.0.4 utf8_1.2.3 digest_0.6.31 withr_2.5.0
#> [5] R6_2.5.1 lifecycle_1.0.3 magrittr_2.0.3 evaluate_0.20
#> [9] pillar_1.8.1 rlang_1.0.6 cli_3.6.0 rstudioapi_0.14
#> [13] fs_1.6.1 generics_0.1.3 vctrs_0.5.2 rmarkdown_2.20
#> [17] tools_4.2.2 glue_1.6.2 xfun_0.37 yaml_2.3.7
#> [21] fastmap_1.1.0 compiler_4.2.2 pkgconfig_2.0.3 htmltools_0.5.4
#> [25] tidyselect_1.2.0 knitr_1.42 tibble_3.1.8Metadata
Metadata
Assignees
Labels
No labels