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_cols() treating data frame with 0 columns as NULL, i.e. not contributing #5366

Closed
wants to merge 1 commit into from

Conversation

romainfrancois
Copy link
Member

closes #5300. This is labelled as a documentation issu in #5300 but I don't think it hurts to ignore 0 columns data frames.

library(dplyr, warn.conflicts = FALSE)

df <- data.frame(x = 1:3)
bind_cols(df, data.frame())
#>   x
#> 1 1
#> 2 2
#> 3 3

Created on 2020-06-29 by the reprex package (v0.3.0.9001)

@romainfrancois
Copy link
Member Author

Actually that does not seem to be a good idea, for the edge case when there are only 0 columns data frames, as you then lose the number of rows:

library(dplyr, warn.conflicts = FALSE)

df <- vctrs::new_data_frame(list(), n = 5L)
bind_cols(df)
#> # A tibble: 0 x 0

Created on 2020-06-29 by the reprex package (v0.3.0.9001)

@lionel-
Copy link
Member

lionel- commented Jun 30, 2020

I think we should be consistent with the recycling rules.

@romainfrancois romainfrancois deleted the bind_cols_df_0 branch June 30, 2020 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The behavior of bind_cols with empty data frames has changed
2 participants