【发布时间】:2020-07-24 19:39:09
【问题描述】:
我正在尝试获取分组 BigQuery 表中变量的分位数,但出现以下错误:
Error: Job 'xxxxx' failed
Syntax error: Expected end of input but got keyword WITHIN at [1:45] [invalidQuery]
Reprex 在下面。
# NOTE: for reprex to work, you must have BIGQUERY_TEST_PROJECT envvar set to name of project which has billing set up and to which you have write access
library(DBI)
library(bigrquery)
library(dplyr)
billing <- bq_test_project()
con <- dbConnect(
bigrquery::bigquery(),
project = "publicdata",
dataset = "samples",
billing = billing
)
natality <- tbl(con, "natality")
natality %>%
group_by(year) %>%
summarize(q25 = quantile(weight_pounds,0.25),
q50 = median(weight_pounds),
q75 = quantile(weight_pounds,0.75)
)
任何人都知道一种解决方法,也许是通过在summarise() 调用中通过sql() 提供SQL 代码?
谢谢!
【问题讨论】:
-
您找到解决方法了吗?我面临着和你完全相同的问题。
-
中位数也给了我同样的错误......
-
@Ploulack 查看下面的答案
标签: r google-bigquery bigrquery