-
Notifications
You must be signed in to change notification settings - Fork 418
names repair #1092
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
Comments
Reprex of underlying problem: library(tidyr)
L <- list(0:1, 0:1, 0:1)
crossing(!!!L)
#> Error: Column names `<int>` and `<int>` must not be duplicated. Created on 2021-02-17 by the reprex package (v1.0.0) Somewhat related to #1060 — there's a general question of how we should handle unnamed inputs. |
The root cause here is a little different; rather than naming an unnamed list, it comes via That said, I don't think we'd want to be inconsistent with L <- list(0:1, 0:1, 0:1)
tibble::tibble(!!!L)
#> Error: Column names `<int>` and `<int>` must not be duplicated. Created on 2021-02-18 by the reprex package (v1.0.0) So maybe we need to adjust |
Note that some of the current library(tidyr)
L <- list(0:1, 2:3)
crossing(!!!L, .name_repair = "universal")
#> New names:
#> * `<int>` -> .int....1
#> * `<int>` -> .int....2
#> # A tibble: 4 x 2
#> .int....1 .int....2
#> <int> <int>
#> 1 2 2
#> 2 2 3
#> 3 3 2
#> 4 3 3 Created on 2021-03-03 by the reprex package (v1.0.0) This happens because library(rlang)
good <- quos(1:2, 3:4)
bad <- quos(!!!list(1:2, 3:4))
quos_auto_name(good)
#> <list_of<quosure>>
#>
#> $`1:2`
#> <quosure>
#> expr: ^1:2
#> env: global
#>
#> $`3:4`
#> <quosure>
#> expr: ^3:4
#> env: global
quos_auto_name(bad)
#> <list_of<quosure>>
#>
#> $`<int>`
#> <quosure>
#> expr: ^<int: 1L, 2L>
#> env: empty
#>
#> $`<int>`
#> <quosure>
#> expr: ^<int: 3L, 4L>
#> env: empty Created on 2021-03-03 by the reprex package (v1.0.0) As a result, when |
Uh oh!
There was an error while loading. Please reload this page.
There is no good option for unnamed columns in crossing. Everything gives something undesirable. You can get what you want if you write your own function but its too much work compared to how easy expand.grid is to use. One possibility is to allow .name.repair to accept a prefix so that one could just write name.repair = "V" or maybe it could just default to that.
The text was updated successfully, but these errors were encountered: