tests/testthat/_snaps/unnest_tree.md

unnest_tree checks arguments (#163)

Code
  (expect_error(unnest_tree(1L)))
Output
  <error/tibblify-error-invalid_data_frame>
  Error in `unnest_tree()`:
  ! `x` must be a data frame.
Code
  (expect_error(unnest_tree(df, id_col = "not-there")))
Output
  <error/vctrs_error_subscript_oob>
  Error in `unnest_tree()`:
  ! Can't select columns that don't exist.
  x Column `not-there` doesn't exist.
Code
  (expect_error(unnest_tree(df, id_col = 1:2)))
Output
  <error/tibblify-error-invalid_column_selection>
  Error in `unnest_tree()`:
  ! `id_col` must select 1 column, not 2.
Code
  (expect_error(unnest_tree(df, id_col, children = "not-there")))
Output
  <simpleError in unnest_tree(df, id_col, children = "not-there"): unused argument (children = "not-there")>
Code
  (expect_error(unnest_tree(df, id_col, children = 1:2)))
Output
  <simpleError in unnest_tree(df, id_col, children = 1:2): unused argument (children = 1:2)>
Code
  (expect_error(unnest_tree(df, children, children)))
Output
  <error/tibblify-error-args_same_value>
  Error in `unnest_tree()`:
  ! `child_col` must be different from `id_col`.
Code
  (expect_error(unnest_tree(df, id, children, level_to = 1L)))
Output
  <error/vctrs_error_cast>
  Error in `unnest_tree()`:
  ! Can't convert `level_to` <integer> to <character>.
Code
  (expect_error(unnest_tree(df, id, children, level_to = "id")))
Output
  <error/rlang_error>
  Error in `unnest_tree()`:
  ! `level_to` must not be a column in `x`.
Code
  (expect_error(unnest_tree(df, id, children, level_to = c("a", "b"))))
Output
  <error/vctrs_error_assert_size>
  Error in `unnest_tree()`:
  ! `level_to` must have size 1, not size 2.
Code
  (expect_error(unnest_tree(df, id, children, parent_to = "level")))
Output
  <error/tibblify-error-args_same_value>
  Error in `unnest_tree()`:
  ! `parent_to` must be different from `level_to`.
Code
  (expect_error(unnest_tree(df, id, children, parent_to = 1L)))
Output
  <error/vctrs_error_cast>
  Error in `unnest_tree()`:
  ! Can't convert `parent_to` <integer> to <character>.
Code
  (expect_error(unnest_tree(df, id, children, parent_to = "id")))
Output
  <error/rlang_error>
  Error in `unnest_tree()`:
  ! `parent_to` must not be a column in `x`.
Code
  (expect_error(unnest_tree(df, id, children, parent_to = c("a", "b"))))
Output
  <error/vctrs_error_assert_size>
  Error in `unnest_tree()`:
  ! `parent_to` must have size 1, not size 2.
Code
  (expect_error(unnest_tree(df, id, children, ancestors_to = "level")))
Output
  <error/tibblify-error-args_same_value>
  Error in `unnest_tree()`:
  ! `ancestors_to` must be different from `level_to`.
Code
  (expect_error(unnest_tree(df, id, children, ancestors_to = "parent")))
Output
  <error/tibblify-error-args_same_value>
  Error in `unnest_tree()`:
  ! `ancestors_to` must be different from `parent_to`.
Code
  (expect_error(unnest_tree(df, id, children, ancestors_to = 1L)))
Output
  <error/vctrs_error_cast>
  Error in `unnest_tree()`:
  ! Can't convert `ancestors_to` <integer> to <character>.
Code
  (expect_error(unnest_tree(df, id, children, ancestors_to = "id")))
Output
  <error/rlang_error>
  Error in `unnest_tree()`:
  ! `ancestors_to` must not be a column in `x`.
Code
  (expect_error(unnest_tree(df, id, children, ancestors_to = c("a", "b"))))
Output
  <error/vctrs_error_assert_size>
  Error in `unnest_tree()`:
  ! `ancestors_to` must have size 1, not size 2.

unnest_tree checks child col type (#163)

Code
  (expect_error(unnest_tree(df, id, children)))
Output
  <error/rlang_error>
  Error in `unnest_tree()`:
  ! `children` must be a list, not the number 1.
Code
  (expect_error(unnest_tree(df2, id, children)))
Output
  <error/rlang_error>
  Error in `unnest_tree()`:
  ! In child 1.
  Caused by error:
  ! `Each child` must be a data frame or `NULL`, not the number 1.
Code
  (expect_error(unnest_tree(df, id, children)))
Output
  <error/rlang_error>
  Error in `unnest_tree()`:
  ! In child 1.
  Caused by error:
  ! `Each child` must be a data frame or `NULL`, not the number 1.

unnest_tree can handle children of different types (#163)

Code
  (expect_error(unnest_tree(df, id, children)))
Output
  <error/vctrs_error_ptype2>
  Error in `unnest_tree()`:
  ! Can't combine `out_ptype$id` <integer> and `x$id` <character>.

unnest_tree checks ids (#163)

Code
  (expect_error(unnest_tree(df_duplicated, id, children)))
Output
  <error/rlang_error>
  Error in `unnest_tree()`:
  ! Each value of column id must be unique.
  i The elements at locations 1 and 2 are duplicated.
Code
  (expect_error(unnest_tree(df_na, id, children)))
Output
  <error/rlang_error>
  Error in `unnest_tree()`:
  ! Each value of column id must be non-missing.
  i Element 2 is missing.


Try the tibblify package in your browser

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

tibblify documentation built on May 9, 2026, 5:07 p.m.