Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back flatmap #405

Closed
hadley opened this issue Nov 6, 2017 · 2 comments · Fixed by #912
Closed

Bring back flatmap #405

hadley opened this issue Nov 6, 2017 · 2 comments · Fixed by #912
Labels
feature a feature request or enhancement map 🗺️
Milestone

Comments

@hadley
Copy link
Member

hadley commented Nov 6, 2017

as map_flat_type.

@hadley hadley added the feature a feature request or enhancement label Feb 4, 2018
@hadley hadley added help wanted ❤️ we'd love your help! map 🗺️ and removed help-wanted labels May 5, 2018
@cderv
Copy link
Contributor

cderv commented May 6, 2018

If is ok, I can work on this as it is help wanted. Will do a PR shortly.

@lionel- lionel- added this to the vctrs milestone Nov 30, 2018
@hadley
Copy link
Member Author

hadley commented Aug 27, 2022

@hadley hadley modified the milestones: vctrs, 0.4.0 Aug 27, 2022
@hadley hadley removed the help wanted ❤️ we'd love your help! label Sep 2, 2022
hadley added a commit that referenced this issue Sep 8, 2022
The key idea is to introduce a new family of "combining" functions: `list_c()`, `list_rbind()`, and `list_cbind()`, which replace `flatten_lgl()`, `flatten_int()`, `flatten_dbl()`, `flatten_chr()` (now `list_c()`), `flatten_dfc()` (`list_cbind()`), and `flatten_dfr()` (`list_rbind()`). The new functions are straightforward wrappers around vctrs functions, but somehow feel natural in purrr to me. 

This leaves `flatten()`, which had a rather idiosyncratic interface. It's now been replaced by `list_flatten()` which now always removes a single layer of list hierarchy (and nothing else). While working on this I realised that this was actually what `splice()` did, so overall this feels like a major improvement in naming consistency.

With those functions in place we can deprecate `map_dfr()` and `map_dfc()` which are actually "flat" map functions because they combine, rather than simplify, the results. They have never actually belonged with `map_int()` and friends because they don't satisfy the invariant `length(map(.x, .f)) == length(.x)`, and `.f` must return a length-1 result. This also strongly implies that `flat_map()` would just be `map_c()` and is thus not necessary.

* Fixes #376 by deprecating `map_dfc()`
* Fixes #405 by clearly ruling against `map_c()`
* Fixes #472 by deprecating `map_dfr()`
* Fixes #575 by introducing `list_c()`, `list_rbind()`, and `list_cbind()`
* Fixes #757 by deprecating `flatten_dfr()` and `flatten_dfc()`
* Fixes #758 by introducing `list_rbind()` and `list_cbind()`
* Part of #900
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement map 🗺️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants