You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See the following example. When translating custom function, the argument g is ignored. Will it be supported?
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 x 1#> mean_x#> <dbl>#> 1 0.319data|>dtplyr::lazy_dt() |>
f()
#> Error: object 'g' not found#> Caused by error in `dplyr::all_of()`:#> object 'g' not found
f(data, g="g")
#> # A tibble: 2 x 2#> g mean_x#> <chr> <dbl>#> 1 A 0.266#> 2 B 0.372data|>dtplyr::lazy_dt() |>
f(g="g")
#> Error: object 'g' not found#> Caused by error in `dplyr::all_of()`:#> object 'g' not found
@markfairbanks Still fails in such circumstances (seemingly, function calls in functions can not access environment variables, either):
library(dplyr)
#> #> Attaching package: 'dplyr'#> The following objects are masked from 'package:stats':#> #> filter, lag#> The following objects are masked from 'package:base':#> #> intersect, setdiff, setequal, union
library(dtplyr)
f<-function(x, y, .v="x") {
inner_join(
mutate(x, a=.v),
y,
by=character()
)
}
x<-data.frame(a="y")
y<-data.frame(b="x")
f(x, y)
#> a b#> 1 x x
lazy_dt(x) |>
f(y)
#> Error in .checkTypos(e, names_x): Object '.v' not found. Perhaps you intended .cross_join_col
See the following example. When translating custom function, the argument
g
is ignored. Will it be supported?Created on 2021-12-06 by the reprex package (v2.0.1)
Session info
The text was updated successfully, but these errors were encountered: