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

pass environment to eval_select in across #318

Merged
merged 4 commits into from Feb 6, 2022

Conversation

eutwt
Copy link
Collaborator

@eutwt eutwt commented Dec 6, 2021

closes #317

Reprex after PR commits:

set.seed(1)
data <- data.frame(g = LETTERS[1:2], x = runif(2))
f <- function(x, g = NULL) {
    x |> 
        dplyr::group_by(dplyr::across(dplyr::all_of(g))) |> 
        dplyr::summarise(mean_x = mean(.data[["x"]]))
}
f(data)
#> # A tibble: 1 × 1
#>   mean_x
#>    <dbl>
#> 1  0.319

data |> 
    dtplyr::lazy_dt() |> 
    f()
#> Source: local data table [1 x 1]
#> Call:   `_DT1`[, .(mean_x = mean(x))]
#> 
#>   mean_x
#>    <dbl>
#> 1  0.319
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results

f(data, g = "g")
#> # A tibble: 2 × 2
#>   g     mean_x
#>   <chr>  <dbl>
#> 1 A      0.266
#> 2 B      0.372

data |> 
    dtplyr::lazy_dt() |> 
    f(g = "g")
#> Source: local data table [2 x 2]
#> Call:   `_DT2`[, .(mean_x = mean(x)), keyby = .(g)]
#> 
#>   g     mean_x
#>   <chr>  <dbl>
#> 1 A      0.266
#> 2 B      0.372
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results

Created on 2021-12-06 by the reprex package (v2.0.1)

@eutwt
Copy link
Collaborator Author

eutwt commented Dec 6, 2021

I'm not sure I'm using the right terminology in the NEWS bullet and test description. Please correct me if it's inaccurate.

@markfairbanks markfairbanks merged commit aea63d9 into tidyverse:main Feb 6, 2022
@eutwt eutwt mentioned this pull request Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot detect custom function arguments
2 participants