diff --git a/R/list-transpose.R b/R/list-transpose.R index 136d60c3..9e76f033 100644 --- a/R/list-transpose.R +++ b/R/list-transpose.R @@ -69,7 +69,13 @@ list_transpose <- function(x, simplify = NA, ptype = NULL, default = NULL) { - vec_check_list(x) + if(!is.list(x)) { + cli::cli_abort( + "{.arg x} must be a list, not {.obj_type_friendly {x}}", + arg = x + ) + } + check_dots_empty() if (length(x) == 0) { diff --git a/tests/testthat/_snaps/list-transpose.md b/tests/testthat/_snaps/list-transpose.md index 7b5ab4a1..df1f84a8 100644 --- a/tests/testthat/_snaps/list-transpose.md +++ b/tests/testthat/_snaps/list-transpose.md @@ -57,7 +57,7 @@ list_transpose(10) Condition Error in `list_transpose()`: - ! `x` must be a list, not the number 10. + ! `x` must be a list, not a number Code list_transpose(list(1), template = mean) Condition diff --git a/tests/testthat/test-list-transpose.R b/tests/testthat/test-list-transpose.R index 272c8a49..724fbab7 100644 --- a/tests/testthat/test-list-transpose.R +++ b/tests/testthat/test-list-transpose.R @@ -130,3 +130,9 @@ test_that("validates inputs", { list_transpose(list(1), template = mean) }) }) + +test_that("works on data frames", { + expect_no_error( + list_transpose(mtcars) + ) +})