infer
infer copied to clipboard
`generate`ing without `specify`
The generate() default variables = !!response_expr(x) trips up when x has yet to
be passed to specify and errors uninformatively:
library(infer)
mtcars %>%
generate(reps = 10, type = "bootstrap")
#> Error: The `variables` argument should be one or more unquoted variable names (not strings in quotation marks).
We might want to adjust the default (or the logic that handles it) to allow
for generateing without specifying, depending on how much we want to support
off-label usage of infer verbs.
Another option is to warn/message when one of the core verbs is called
without specify() having been called first.
Note that the arguments are handled just fine after passing to specify:
mtcars %>%
specify(response = cyl) %>%
generate(reps = 10, type = "bootstrap")
#> Response: cyl (numeric)
#> Explanatory: ()
#> # A tibble: 320 × 2
#> # Groups: replicate [10]
#> replicate cyl
#> <int> <dbl>
#> 1 1 4
#> 2 1 8
#> 3 1 8
#> 4 1 4
#> 5 1 8
#> 6 1 4
#> 7 1 8
#> 8 1 8
#> 9 1 8
#> 10 1 4
#> # … with 310 more rows
Created on 2022-04-19 by the reprex package (v2.0.1)