tidyverse / purrr

A functional programming toolkit for R
https://purrr.tidyverse.org/
Other
1.28k stars 272 forks source link

`list_transpose()` and data frames #1109

Closed mmuurr closed 3 months ago

mmuurr commented 1 year ago

With the transition from transpose() to list_transpose() comes this (new) incompatibility:

> purrr::list_transpose(mtcars)
# Error in `purrr::list_transpose()`:
# ! `x` must be a list, not a <data.frame> object.
# Run `rlang::last_trace()` to see where the error occurred.

> is.list(mtcars)
# [1] TRUE

transpose(), however, still works as expected.

Was this an intentional change? (If there's any voting on the matter, I cast one vote to allow list_transpose() to operate on data frames, which are -- after all -- lists :-))

{purrr} v1.0.2

hadley commented 4 months ago

I agree. I think it would make sense to replace vec_check_list() (which has been superseded anyway) with a custom error using is.list().