-
Notifications
You must be signed in to change notification settings - Fork 415
Cannot perform a series of crossings using reduce: <tibble> must not be duplicated. #992
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
Somewhat more minimal reprex: library(tidyr)
x <- list(tibble(a=1:2), tibble(b=2:4))
purrr::reduce(x, crossing)
#> Error: Column name `<tibble>` must not be duplicated. Created on 2020-08-28 by the reprex package (v0.3.0.9001) But weirdly the problem goes away if you insert an anonymous function: library(tidyr)
x <- list(tibble(a=1:2), tibble(b=2:4))
purrr::reduce(x, function(x, y) {crossing(x, y)})
#> # A tibble: 6 x 2
#> a b
#> <int> <int>
#> 1 1 2
#> 2 1 3
#> 3 1 4
#> 4 2 2
#> 5 2 3
#> 6 2 4 Created on 2020-08-28 by the reprex package (v0.3.0.9001) Any ideas @lionel-? |
It looks like I think the arguments are forced because of: https://github.com/tidyverse/purrr/blob/5de5ad293b817d8a6baea32cc4415487d71da955/R/reduce.R#L160 One solution might be to repair the names in |
I think I've hit this as well, though in my case it's only a single call to Error: Column name `tibble(...)` must not be duplicated.
Use .name_repair to specify repair.
Run `rlang::last_error()` to see where the error occurred.
> rlang::last_error()
x
+-<error/tibble_error_column_names_must_be_unique>
| Column name `tibble(...)` must not be duplicated.
| Use .name_repair to specify repair.
\-<error/vctrs_error_names_must_be_unique>
Names must be unique.
Backtrace:
1. `%>%`(...)
3. tidyr::crossing(...)
4. tidyr::expand_grid(!!!cols, .name_repair = .name_repair)
6. tibble:::as_tibble.list(out, .name_repair = .name_repair)
7. tibble:::lst_to_tibble(x, .rows, .name_repair, col_lengths(x))
8. tibble:::set_repaired_names(x, repair_hint = TRUE, .name_repair)
10. tibble:::repaired_names(...)
13. vctrs::vec_as_names(...)
15. vctrs:::validate_unique(names = names, arg = arg)
16. vctrs:::stop_names_must_be_unique(names, arg)
17. vctrs:::stop_names(...)
18. vctrs:::stop_vctrs(class = c(class, "vctrs_error_names"), ...)
Run `rlang::last_trace()` to see the full context. Some investigation in search of a minimal repex shows sensitivity to naming and tibble content which, to me, is curious. crossing(tibble(name000001 = 1, name000002 = 93, name000003 = 16, name000004 = 65, name000005 = 24),
tibble(name000006 = c(6, 7, 8), name000007Efficie = c(7, 8, 9))) # works
crossing(tibble(name000001 = 1, name000002 = 93, name000003 = 16, name000004 = 65, name000005 = 24),
tibble(name000006 = c(6, 7, 8), name000007Efficien = c(7, 8, 9))) # fails due to one additional character in name of second tibble's second column
crossing(tibble(name000001 = 1, name000002 = 93, name000003 = 16, name000004 = 65, name000005 = 24),
tibble(name000006 = 6, name000007Efficien = 7)) # extra character works with different data |
@eutwt that actually looks very broken? It should be like: library(tidyr)
x <- tibble(name000001 = 1, name000002 = 93, name000003 = 16, name000004 = 65, name000005 = 24)
y <- tibble(name000006 = c(6, 7, 8), name000007Efficien = c(7, 8, 9))
crossing(x, y)
#> # A tibble: 3 × 7
#> name000001 name000002 name000003 name000004 name000005 name000006
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 93 16 65 24 6
#> 2 1 93 16 65 24 7
#> 3 1 93 16 65 24 8
#> # … with 1 more variable: name000007Efficien <dbl> Created on 2021-08-26 by the reprex package (v2.0.0.9000) |
@DavisVaughan Yes thank you, sorry about that. I noticed after I posted it was incorrect. I've deleted the erroneous comment. |
I'm trying to reduce crossings using a list of tibbles, but I get unexpected error: (
<tibble>
must not be duplicated).Created on 2020-07-07 by the reprex package (v0.3.0)
Session info
The text was updated successfully, but these errors were encountered: