-
Notifications
You must be signed in to change notification settings - Fork 417
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
expand_grid with tibbles fails depending on values #1116
Comments
Seems like a tidyr issue. So I'll move it there. Related to: |
A quick fix is to assign the inlined tibbles to variables, then call library(tidyr)
df1 <- dplyr::tibble(
fruit = c("Apple", "Banana"),
fruit_id = c("a", "b")
)
df2 <- dplyr::tibble(
status_id = c("c", "d"),
status = c("cut_neatly", "devoured"),
)
expand_grid(df1, df2)
#> # A tibble: 4 x 4
#> fruit fruit_id status_id status
#> <chr> <chr> <chr> <chr>
#> 1 Apple a c cut_neatly
#> 2 Apple a d devoured
#> 3 Banana b c cut_neatly
#> 4 Banana b d devoured Created on 2021-04-27 by the reprex package (v1.0.0) Sensitivity to input comes from the fact that library(rlang)
quos_auto_name(quos(
dplyr::tibble(
fruit = c("Apple", "Banana"),
fruit_id = c("a", "b")
),
dplyr::tibble(
status_id = c("c", "d"),
status = c("cut", "devoured")
)
))
#> <list_of<quosure>>
#>
#> $`dplyr::tibble(...)`
#> <quosure>
#> expr: ^dplyr::tibble(fruit = c("Apple", "Banana"), fruit_id = c("a", "b"))
#> env: global
#>
#> $`dplyr::tibble(status_id = c("c", "d"), status = c("cut", "devoured"))`
#> <quosure>
#> expr: ^dplyr::tibble(status_id = c("c", "d"), status = c("cut", "devoured"))
#> env: global
quos_auto_name(quos(
dplyr::tibble(
fruit = c("Apple", "Banana"),
fruit_id = c("a", "b")
),
dplyr::tibble(
status_id = c("c", "d"),
status = c("cut_neatly", "devoured"),
)
))
#> <list_of<quosure>>
#>
#> $`dplyr::tibble(...)`
#> <quosure>
#> expr: ^dplyr::tibble(fruit = c("Apple", "Banana"), fruit_id = c("a", "b"))
#> env: global
#>
#> $`dplyr::tibble(...)`
#> <quosure>
#> expr: ^dplyr::tibble(status_id = c("c", "d"), status = c("cut_neatly",
#> "devoured"), )
#> env: global Created on 2021-04-27 by the reprex package (v1.0.0) |
I am trying to create a tibble that contains all combinations of its elements, except for some nesting. In doing so, I encountered the following sensitivity of
expand_grid
with respect to its contents.Is this a bug?
Created on 2021-04-27 by the reprex package (v1.0.0)
The text was updated successfully, but these errors were encountered: