首页 > 解决方案 > `across` 是否适用于 dplyr 火花帧的汇总?

问题描述

在使用 a而不是常规时,我遇到了与and动词summarize结合使用的问题。acrosswheretbl_sparktbl

初始化小标题

temp <- tibble(
  a = c(1, 2, NA),
  c = c(4, 8, NA),
  b = c("A", NA, "B")
)

temp_spark <- sdf_copy_to(sc, temp, "temp_spark")

我的尝试

> temp %>% summarise(across(where(is.numeric), ~mean(.x, na.rm = TRUE)))
# A tibble: 1 x 2
      a     c
  <dbl> <dbl>
1   1.5     6
> temp_spark %>% summarise(across(where(is.numeric), ~mean(.x, na.rm = TRUE)))
Error in UseMethod("escape") : 
  no applicable method for 'escape' applied to an object of class "function"

标签: rdplyrsparklyr

解决方案


推荐阅读