Open
Description
This is a pathological case, but actually does come up in the wild, see tidymodels/workflows#48
When as_tibble()
is given a matrix with duplicate names, I see two issues:
-
The warning message is about not having any column names at all, which doesn't seem right
-
It is possible for the result to still have duplicate names after the repair if the original column names were already
V*
where*
is a numeric value.
library(tibble)
x <- matrix(1:2, ncol = 2, dimnames = list(NULL, c("V2", "V2")))
# lifecycle warning, but its an odd warning
as_tibble(x)
#> Warning: The `x` argument of `as_tibble.matrix()` must have column names if `.name_repair` is omitted as of tibble 2.0.0.
#> Using compatibility `.name_repair`.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.
#> # A tibble: 1 x 2
#> V2 V2
#> <int> <int>
#> 1 1 2
# warning is silent now, and still no fix
as_tibble(x)
#> # A tibble: 1 x 2
#> V2 V2
#> <int> <int>
#> 1 1 2
I wonder if in the duplicated names case we should be using vec_as_names(names, repair = "unique")
or something similar to that, rather than using this V*
repair. The V*
repair seems reasonable when there are no names at all, but when some exist I think they should be used and just repaired in the standard way with ...i