I suggest we at least we mark as_vector(), simplify(), simplify_all(), flatten(), and flatten_*() as questioning and remove from the function index. The semantics of these functions are not super clear, and I'm not sure it's worth completely nailing them down because many of the problems they were originally designed to solve have moved into tidyr. Their use in their purrr docs reveals few compelling uses cases:
-
as_vector() is only used in its own examples.
-
simplify() (a version of as_vector() that returns x if it can simplify) isn't used at all.
-
simplify_all() is used with the output of transpose(). The most compelling use case is with safely() to get lists of error and results. But I suspect we could tackle this a different way, perhaps with a list_transpose() inspired by the work we've done in unnest_longer()/unnest_wider() or possibly powered by vec_simplify().
-
flatten() is only used in its own examples. I can see flatten() being useful in conjunction with map() but it might be easier to create the flat_map() functions directly.
Long term, if we do discover that flatten() and simplify() are useful enough to bother fully fleshing out their semantics, I'd suggest deprecating them and introducing new list_flatten() and list_simplify().
Additionally, it might be worth deprecating flatten_dfc() and flatten_dfr() as they have poor semantics (#648, #757). They are similar to both dplyr::bind_rows(x) and vctrs::vec_rbind(!!!x). If we think it's unappealing to recommend a vctrs function we could add list_rbind <- function(x) vctrs::vec_rbind(!!!x) (and similar for list_cbind()). I think we'd probably require individual elements to be data frames.
I suggest we at least we mark
as_vector(),simplify(),simplify_all(),flatten(), andflatten_*()as questioning and remove from the function index. The semantics of these functions are not super clear, and I'm not sure it's worth completely nailing them down because many of the problems they were originally designed to solve have moved into tidyr. Their use in their purrr docs reveals few compelling uses cases:as_vector()is only used in its own examples.simplify()(a version ofas_vector()that returnsxif it can simplify) isn't used at all.simplify_all()is used with the output oftranspose(). The most compelling use case is withsafely()to get lists of error and results. But I suspect we could tackle this a different way, perhaps with alist_transpose()inspired by the work we've done inunnest_longer()/unnest_wider()or possibly powered byvec_simplify().flatten()is only used in its own examples. I can seeflatten()being useful in conjunction withmap()but it might be easier to create theflat_map()functions directly.Long term, if we do discover that
flatten()andsimplify()are useful enough to bother fully fleshing out their semantics, I'd suggest deprecating them and introducing newlist_flatten()andlist_simplify().Additionally, it might be worth deprecating
flatten_dfc()andflatten_dfr()as they have poor semantics (#648, #757). They are similar to bothdplyr::bind_rows(x)andvctrs::vec_rbind(!!!x). If we think it's unappealing to recommend a vctrs function we could addlist_rbind <- function(x) vctrs::vec_rbind(!!!x)(and similar forlist_cbind()). I think we'd probably require individual elements to be data frames.