-
Notifications
You must be signed in to change notification settings - Fork 175
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
Add support for across() #480
Comments
I think there is still an issue with this functionality; reprex below ( db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
iris_df <- head(iris, 2)
iris_db <- dplyr::copy_to(db, iris_df)
vars <- c("Sepal.Length", "Sepal.Width")
f_mutate <- function(d, v) {
dplyr::mutate(d, dplyr::across(dplyr::all_of(v), floor))
}
f_mutate(iris_df, vars)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5 3 1.4 0.2 setosa
#> 2 4 3 1.4 0.2 setosa
f_mutate(iris_db, vars)
#> Error: object 'v' not found
dplyr::mutate(iris_db, dplyr::across(dplyr::all_of(vars), floor))
#> # Source: lazy query [?? x 5]
#> # Database: sqlite 3.34.1 [:memory:]
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> <int> <int> <int> <int> <int>
#> 1 5 3 1 0 0
#> 2 4 3 1 0 0 Created on 2021-04-01 by the reprex package (v1.0.0) |
I've also encountered the problem described by @shntnu here. If anyone else stumbles across this issue I was able to work around it by either having db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
iris_df <- head(iris, 2)
iris_db <- dplyr::copy_to(db, iris_df)
vars <- c("Sepal.Length", "Sepal.Width")
f_mutate <- function(d, v) {
dplyr::mutate(d, dplyr::across(dplyr::all_of(v), floor))
}
f_mutate_2 <- function(d, v) {
env <- rlang::current_env()
dplyr::mutate(d, dplyr::across(dplyr::all_of(local(v, env)), floor))
}
f_mutate(iris_db, vars)
#> Error: object 'v' not found
f_mutate_2(iris_db, vars)
#> # Source: lazy query [?? x 5]
#> # Database: sqlite 3.36.0 [:memory:]
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> <int> <int> <dbl> <dbl> <chr>
#> 1 5 3 1.4 0.2 setosa
#> 2 4 3 1.4 0.2 setosa Created on 2021-10-23 by the reprex package (v2.0.1) |
No description provided.
The text was updated successfully, but these errors were encountered: