-
Notifications
You must be signed in to change notification settings - Fork 130
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
Provide rbind() and cbind() methods #909
base: main
Are you sure you want to change the base?
Conversation
R/class-tbl_df.R
Outdated
|
||
#' @rawNamespace if (getRversion() >= "4.0.0") S3method(cbind, tbl_df) | ||
if (getRversion() >= "4.0.0") cbind.tbl_df <- function(...) { | ||
vec_cbind(...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like it is reasonable that if users want to use the optional arguments in vec_c/rbind()
, then they should just use vec_c/rbind()
instead, but I wanted to check here if that is also what you are thinking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Should we do vec_cbind(!!!list(...))
instead, to avoid passing through optional arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would work yes. Or should that be list2()
? Or would it be weird to use !!!
with base generics? I don't really know what to think about these mixed interfaces.
After #890, do we still want to use |
Tried that, doesn't work: I still wonder what the desired semantics for |
Docs say "you need to carefully check and think about it", I guess we're fine here. |
Just started the revdeps with library(revdepcheck)
pkgs <- unique(c(cran_revdeps("tidyr"), cran_revdeps("tibble"), cran_revdeps("dplyr")))
cloud_check(revdep_packages = pkgs) |
Thanks @hadley! This shows that:
Do we have an easy way to send a message to all affected maintainers? |
Before we notify the maintainers, I think it would be worth digging into 2-5 of the failures in more detail to see if there's a common underlying cause. |
We can find the underlying cause by replacing egor library(tibble)
rbind(tibble(.b = integer()), tibble(a = 1, .b = 2))
#> # A tibble: 1 × 2
#> a .b
#> <dbl> <dbl>
#> 1 1 2
vctrs::vec_rbind(tibble(.b = integer()), tibble(a = 1, .b = 2))
#> # A tibble: 1 × 2
#> .b a
#> <dbl> <dbl>
#> 1 2 1 Created on 2021-10-20 by the reprex package (v2.0.1) |
ypr checks for row names in its tests: library(tibble)
row.names(rbind(tibble(a = 1), data.frame(a = c(x = 2))))
#> [1] "1" "x"
row.names(vctrs::vec_rbind(tibble(a = 1), data.frame(a = c(x = 2))))
#> [1] "...1" "x" Created on 2021-10-20 by the reprex package (v2.0.1) |
twoxtwo binds a vector and a tibble: library(tibble)
base::rbind.data.frame(c("a", "b"), tibble(a = 1, b = 2))
#> # A tibble: 2 × 2
#> a b
#> <chr> <chr>
#> 1 a b
#> 2 1 2
vctrs::vec_rbind(c("a", "b"), tibble(a = 1, b = 2))
#> New names:
#> * `` -> ...1
#> * `` -> ...2
#> # A tibble: 2 × 4
#> ...1 ...2 a b
#> <chr> <chr> <dbl> <dbl>
#> 1 a b NA NA
#> 2 <NA> <NA> 1 2 Created on 2021-10-20 by the reprex package (v2.0.1) |
optimall calls library(tibble)
x <- 2
base:::cbind.data.frame(tibble(a = 1), x)
#> a x
#> 1 1 2
vctrs::vec_cbind(tibble(a = 1), x)
#> New names:
#> * `` -> ...2
#> # A tibble: 1 × 2
#> a ...2
#> <dbl> <dbl>
#> 1 1 2 Created on 2021-10-20 by the reprex package (v2.0.1) |
Especially the last issue looks like a serious incompatibility: library(tibble)
x <- 2
base:::cbind.data.frame(tibble(a = 1), x)
#> a x
#> 1 1 2
vctrs::vec_cbind(tibble(a = 1), x)
#> New names:
#> * `` -> ...2
#> # A tibble: 1 × 2
#> a ...2
#> <dbl> <dbl>
#> 1 1 2 Created on 2021-10-20 by the reprex package (v2.0.1) I suggest the following:
This allows us and the maintainers to easier locate the source of a problem: we can gradually replace
Do we still want to pursue this path? |
The story with
I think the important point is the second one. We now at least have a good answer for people who want to be able to combine tibbles without relying on dplyr (i.e. use vctrs). |
Seems like you could link to Similar for |
Agreed, it's a lot of work for limited gain. Depends on how badly we want to support |
for R >= 4.0.0.
Closes #34.