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

bind_rows and list names #1337

Closed
bramtayl opened this issue Aug 24, 2015 · 4 comments
Closed

bind_rows and list names #1337

bramtayl opened this issue Aug 24, 2015 · 4 comments
Labels
feature a feature request or enhancement
Milestone

Comments

@bramtayl
Copy link

It seems like, at the moment, bind_rows, when applied to a list, disregards name information. I've been doing things like this:

test = list(source_1 = data_frame(a = 1), 
            source_2 = data_frame(a = 1) )

1:length(test) %>%
  lapply(function(i)
  test[[i]] %>%
    mutate(name = names(test)[i]) ) %>%
  bind_rows

It seems like a straightforward solution would be to have extra argument which specifies the name of a column to contain list name information.

@hadley hadley added the feature a feature request or enhancement label Aug 24, 2015
@hadley
Copy link
Member

hadley commented Aug 24, 2015

See also #825

@hadley hadley added this to the 0.5 milestone Aug 24, 2015
@bramtayl
Copy link
Author

A similar strategy might be used also be used for row names. Although list names might be more important because they often contain important information for joins etc.

@bramtayl
Copy link
Author

Note also this was at one point a feature of rbindlist from data.table (idcol = TRUE)

@hadley
Copy link
Member

hadley commented Aug 25, 2015

Dplyr will always discard row names because I think they're a bad idea

lionel- added a commit to lionel-/dplyr that referenced this issue Aug 27, 2015
lionel- added a commit to lionel-/dplyr that referenced this issue Aug 27, 2015
lionel- added a commit to lionel-/dplyr that referenced this issue Aug 27, 2015
lionel- added a commit to lionel-/dplyr that referenced this issue Aug 27, 2015
lionel- added a commit to lionel-/dplyr that referenced this issue Aug 27, 2015
lionel- added a commit to lionel-/dplyr that referenced this issue Aug 27, 2015
lionel- added a commit to lionel-/dplyr that referenced this issue Aug 27, 2015
@hadley hadley closed this as completed in 6cf553a Aug 27, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jun 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants