Skip to content
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

Error with auk package #2

Closed
krlmlr opened this issue Apr 18, 2024 · 4 comments · Fixed by #6
Closed

Error with auk package #2

krlmlr opened this issue Apr 18, 2024 · 4 comments · Fixed by #6
Assignees

Comments

@krlmlr
Copy link
Contributor

krlmlr commented Apr 18, 2024

With a variant of cynkra/dplyr#4 (applied on top of the most recent dplyr, our fork is hopelessly outdated):

f <- system.file("extdata/ebd-rollup-ex.txt", package = "auk")
ebd <- auk::read_ebd(f, rollup = FALSE)
auk::auk_rollup(ebd)
#> Error:
#> ℹ In argument: `count = dplyr::coalesce(.data$count, "X")`.
#> Caused by error:
#> ! unused argument (base::quote(c("Setophaga coronata", "Columba livia", "Fulica americana", "Columba livia", "Junco hyemalis", "Columba livia", "Setophaga coronata", "Colaptes auratus", "Loxia curvirostra", "Colaptes auratus")))

Created on 2024-04-18 with reprex v2.1.0

@krlmlr
Copy link
Contributor Author

krlmlr commented Apr 18, 2024

I also can't replay the files collected from running R CMD check with auk, with a similar error.

Will try another package.

@moodymudskipper
Copy link
Collaborator

This seems to be due to some dplyr magic :

df1 <- tibble(a="A")

# these work
mutate(df1, b = paste(a, "X"))
#> # A tibble: 1 × 2
#>   a     b    
#>   <chr> <chr>
#> 1 A     A X
coalesce(df1$a, "X")
#> [1] "A"
transform(df1, b = coalesce(a, "X"))
#>   a b
#> 1 A A

# this doesnt
mutate(df1, b = coalesce(a, "X"))
#> Error:
#> ℹ In argument: `b = coalesce(a, "X")`.
#> Caused by error:
#> ! unused argument (base::quote("A"))
#> Backtrace:
#>      ▆
#>   1. ├─dplyr::mutate(df1, b = coalesce(a, "X"))
#>   2. │ └─collector::collect_and_run()
#>   3. │   └─base::eval(call_to_original, new_caller_env) at collector/R/collector.R:116:3
#>   4. │     └─base::eval(call_to_original, new_caller_env)
#>   5. │       ├─dplyr (local) `<fn>`(df1, b = coalesce(a, "X"))
#>   6. │       └─dplyr:::mutate.data.frame(df1, b = coalesce(a, "X")) at dplyr/R/mutate.R:146:3
#>   7. │         └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by) at dplyr/R/mutate.R:181:3
#>   8. │           ├─base::withCallingHandlers(...) at dplyr/R/mutate.R:268:3
#>   9. │           └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns) at dplyr/R/mutate.R:273:7
#>  10. │             └─mask$eval_all_mutate(quo) at dplyr/R/mutate.R:380:9
#>  11. │               └─dplyr (local) eval() at dplyr/R/data-mask.R:94:7
#>  12. ├─dplyr::coalesce(a, "X")
#>  13. │ └─collector::collect_and_run()
#>  14. │   └─collector:::env_clone_lazy(caller_env) at collector/R/collector.R:104:3
#>  15. │     └─collector:::env_clone_lazy(env_parent(env)) at collector/R/collector.R:126:3
#>  16. │       └─rlang::env_bind_lazy(clone, `:=`(!!nm, !!env[[nm]])) at collector/R/collector.R:132:5
#>  17. ├─base::delayedAssign(x, value = "A", assign.env = y, eval.env = z)
#>  18. └─base::.handleSimpleError(...)
#>  19.   └─dplyr (local) h(simpleError(msg, call))
#>  20.     └─rlang::abort(message, class = error_class, parent = parent, call = error_call) at dplyr/R/conditions.R:235:5

@moodymudskipper
Copy link
Collaborator

I think it's due to a rlang bug, but one we might work around,

At some point in env_clone_lazy we do (here inlined) :

env_bind_lazy(clone, a = "A")
#> Error in (function ()  : unused argument (base::quote("A"))

if we remove the binding first (usually unneeded) this works, and it's ok to do it because at this point we're looping on evaluated variables

@krlmlr
Copy link
Contributor Author

krlmlr commented Apr 18, 2024

Confirming that auk now works, thanks. It is collecting too much data for its calls to n() . Leading to #9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants