【发布时间】:2017-11-08 01:22:53
【问题描述】:
我正在尝试使用 sparklyr 中的 group_by() 和 mutate() 函数来连接组中的行。
这是一个我认为应该可行但不可行的简单示例:
library(sparkylr)
d <- data.frame(id=c("1", "1", "2", "2", "1", "2"),
x=c("200", "200", "200", "201", "201", "201"),
y=c("This", "That", "The", "Other", "End", "End"))
d_sdf <- copy_to(sc, d, "d")
d_sdf %>% group_by(id, x) %>% mutate( y = paste(y, collapse = " "))
我希望它产生的是:
Source: local data frame [6 x 3]
Groups: id, x [4]
# A tibble: 6 x 3
id x y
<fctr> <fctr> <chr>
1 1 200 This That
2 1 200 This That
3 2 200 The
4 2 201 Other End
5 1 201 End
6 2 201 Other End
我收到以下错误:
Error: org.apache.spark.sql.AnalysisException: missing ) at 'AS' near '' '' in selection target; line 1 pos 42
请注意,在 data.frame 上使用相同的代码可以正常工作:
d %>% group_by(id, x) %>% mutate( y = paste(y, collapse = " "))
【问题讨论】:
标签: r data-science sparklyr