-
Notifications
You must be signed in to change notification settings - Fork 57
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
Implement pick()
and use across()
output as a data frame
#341
Comments
Using
|
Not sure the best way to handle this one. At first I thought the way to solve this would be by checking if an input dot was an Simple example: dots_fn <- function(...) {
dots <- enquos(...)
is_top_across <- map(dots, quo_is_call, "across")
is_top_across
} This seems reasonable and works well in the following situations: df %>%
mutate(
# "top" across call treated normally
across(c(x, y), ~ .x + 1),
# nested within another call - treated as a `data.table()` call
row_sum = rowSums(across(c(y, z)))
) However I'm finding this approach can fail when dealing with operations applied to list-columns: library(tidyverse)
list_df <- tibble(a = 1:3, b = 1:3)
df <- tibble(x = c("a", "b"), list_col = list(list_df, list_df))
df %>%
mutate(
list_col = map(list_col, ~ .x %>% mutate(across(c(a, b), ~ .x + 1)))
) Here we would want the I haven't figured out a good workaround yet. |
Actually all we would need to do is catch if |
Updates from Implement So we need to implement |
across()
output as a data framepick()
and use across()
output as a data frame
I think implementing library(dplyr, warn.conflicts = FALSE)
df <- tibble(x = c("a", "a", "b"), y = 1:3, z = 1:3)
df %>%
mutate(row_sum = rowSums(across(c(y, z), sin)))
#> # A tibble: 3 × 4
#> x y z row_sum
#> <chr> <int> <int> <dbl>
#> 1 a 1 1 1.68
#> 2 a 2 2 1.82
#> 3 b 3 3 0.282 Created on 2022-11-03 with reprex v2.0.2 But, I don't see a good way to get this behavior in dtplyr. I'd say this issue should be closed unless you feel differently (and open a new one for |
Oh, didn't see your earlier comments. Seems you have an idea for how to implement, so disregard my comment :) |
The text was updated successfully, but these errors were encountered: