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

Can't use case_if_any() on variables that were just created. #8

Open
olivroy opened this issue Jul 21, 2023 · 0 comments
Open

Can't use case_if_any() on variables that were just created. #8

olivroy opened this issue Jul 21, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@olivroy
Copy link
Owner

olivroy commented Jul 21, 2023

library(dplyr)
#> 
#> Attachement du package : 'dplyr'
#> Les objets suivants sont masqués depuis 'package:stats':
#> 
#>     filter, lag
#> Les objets suivants sont masqués depuis 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(reuseme)
mtcars |> group_by(vs) |> summarise(avg_mpg = mean(mpg), error = case_when(avg_mpg > 20 ~ "Youppi"))
#> # A tibble: 2 × 3
#>      vs avg_mpg error 
#>   <dbl>   <dbl> <chr> 
#> 1     0    16.6 <NA>  
#> 2     1    24.6 Youppi
mtcars |> group_by(vs) |> summarise(avg_mpg = mean(mpg), error = case_if_any(avg_mpg > 20 ~ "Youppi"))
#> Error in `summarise()`:
#> ℹ In argument: `error = case_if_any(avg_mpg > 20 ~ "Youppi")`.
#> ℹ In group 1: `vs = 0`.
#> Caused by error:
#> ! objet 'avg_mpg' introuvable
#> Backtrace:
#>      ▆
#>   1. ├─dplyr::summarise(...)
#>   2. ├─dplyr:::summarise.grouped_df(...)
#>   3. │ └─dplyr:::summarise_cols(.data, dplyr_quosures(...), by, "summarise")
#>   4. │   ├─base::withCallingHandlers(...)
#>   5. │   └─dplyr:::map(quosures, summarise_eval_one, mask = mask)
#>   6. │     └─base::lapply(.x, .f, ...)
#>   7. │       └─dplyr (local) FUN(X[[i]], ...)
#>   8. │         └─mask$eval_all_summarise(quo)
#>   9. │           └─dplyr (local) eval()
#>  10. ├─reuseme::case_if_any(avg_mpg > 20 ~ "Youppi")
#>  11. │ └─base::eval(parse(text = condition[1])) at reuseme/R/case-if-any.R:35:2
#>  12. │   └─base::eval(parse(text = condition[1]))
#>  13. └─base::.handleSimpleError(...)
#>  14.   └─dplyr (local) h(simpleError(msg, call))
#>  15.     └─dplyr (local) handler(cnd)
#>  16.       └─rlang::abort(message, class = error_class, parent = parent, call = error_call)

Created on 2023-07-21 with reprex v2.0.2

@olivroy olivroy added the bug Something isn't working label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant