tests/testthat/_snaps/expand.md

crossing checks for bad inputs

Code
  (expect_error(crossing(x = 1:10, y = quote(a))))
Output
  <error/vctrs_error_scalar_type>
  Error in `crossing()`:
  ! `..2` must be a vector, not a symbol.

expand() respects .name_repair

Code
  out <- df %>% expand(x = x, x = x, .name_repair = "unique")
Message
  New names:
  * `x` -> `x...1`
  * `x` -> `x...2`

crossing() / nesting() respect .name_repair

Code
  out <- crossing(x = x, x = x, .name_repair = "unique")
Message
  New names:
  * `x` -> `x...1`
  * `x` -> `x...2`
Code
  out <- nesting(x = x, x = x, .name_repair = "unique")
Message
  New names:
  * `x` -> `x...1`
  * `x` -> `x...2`

expand_grid() can control name_repair

Code
  (expect_error(expand_grid(x = x, x = x)))
Output
  <error/vctrs_error_names_must_be_unique>
  Error in `expand_grid()`:
  ! Names must be unique.
  x These names are duplicated:
    * "x" at locations 1 and 2.
  i Use argument `.name_repair` to specify repair strategy.
Code
  out <- expand_grid(x = x, x = x, .name_repair = "unique")
Message
  New names:
  * `x` -> `x...1`
  * `x` -> `x...2`

grid_dots() reject non-vector input

Code
  (expect_error(grid_dots(lm(1 ~ 1))))
Output
  <error/vctrs_error_scalar_type>
  Error:
  ! `..1` must be a vector, not a <lm> object.


Try the tidyr package in your browser

Any scripts or data that you put into this service are public.

tidyr documentation built on Feb. 16, 2023, 7:40 p.m.