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_names() #525

Open
lionel- opened this Issue Jul 31, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@lionel-
Member

lionel- commented Jul 31, 2018

To provide a way of combining names prior to flattening:

x <- list(A = list(foo = 1, bar = 2), B = list(baz = 3)

x %>%
  flatten_names(~paste(.x, .y, sep = " :: ")) %>%
  flatten()
#> $`A :: foo`
#> [1] 1
#>
#> $`A :: bar`
#> [1] 2
#>
#> $`B :: baz`
#> [1] 3

The definition would be

flatten_names <- function(.x, .f = paste, ...) { ... }

So this would work as well:

x %>% flatten_names(sep = " :: ")
@hadley

This comment has been minimized.

Member

hadley commented Dec 4, 2018

Or should this be an argument to flatten()? (Like .name_repair in tibble())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment