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
Milestone

Comments

@bramtayl
Copy link

@bramtayl bramtayl commented Aug 24, 2015

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 label Aug 24, 2015
@hadley
Copy link
Member

@hadley hadley commented Aug 24, 2015

See also #825

Loading

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

@bramtayl bramtayl commented Aug 25, 2015

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.

Loading

@bramtayl
Copy link
Author

@bramtayl bramtayl commented Aug 25, 2015

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

Loading

@hadley
Copy link
Member

@hadley hadley commented Aug 25, 2015

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

Loading

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 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants