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

flatten_dfr drops all elements except the first #374

Closed
expersso opened this issue Aug 22, 2017 · 3 comments
Closed

flatten_dfr drops all elements except the first #374

expersso opened this issue Aug 22, 2017 · 3 comments
Labels
bug an unexpected problem or unintended behavior flatten 🌎
Milestone

Comments

@expersso
Copy link

Consider this:

> nrow(iris)
[1] 150
> nrow(flatten_dfr(list(iris, iris, iris)))
[1] 150
> nrow(bind_rows(iris, iris, iris))
[1] 450

I would expect flatten_dfr to simply concatenate the data frame like bind_rows, but it appears to just drop all elements except the first.

@hadley hadley added the bug an unexpected problem or unintended behavior label Feb 5, 2018
@batpigandme
Copy link
Contributor

Assume it's the same reason the flatten test is failing. (So, test works, that's good news!)

  > test_check("purrr")
  [31m──[39m [31m1. Failure: can flatten to a data frame with named lists [39m
  `flatten_dfc(list(1))` did not throw an error.
  
  ══ testthat results  ═══════════════════════════════════════
  OK: 433 SKIPPED: 0 FAILED: 1
  1. Failure: can flatten to a data frame with named lists (@test-flatten.R#78) 

@lionel-
Copy link
Member

lionel- commented Nov 16, 2018

Using rlang::flatten() instead of purrr::flatten() would fix this because it only flattens inner lists. For instance, the following all return the same results:

list(mtcars, mtcars))
rlang::flatten(list(mtcars, mtcars)))           # No inner list
rlang::flatten(list(mtcars, list(mtcars))))     # Flattened inner list

We're still not sure what the proper flattening semantics are...

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

hadley commented Aug 27, 2022

This seems to be the same problem as #757 — in this case flatten_dfr() appears to be column-binding, not row-binding.

@hadley hadley closed this as completed Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior flatten 🌎
Projects
None yet
Development

No branches or pull requests

4 participants