我想在 bigrquery 中使用 dplyr 语法获得大查询中列的第 20 个百分位,但我不断收到以下错误。这是一个可重现的示例:
library(bigrquery)
library(dplyr)
library(DBI)
billing <- YOUR_BILLING_INFO
con <- dbConnect(
bigrquery::bigquery(),
project = "publicdata",
dataset = "samples",
billing = billing
)
natality <- tbl(con, "natality")
natality %>%
filter(year %in% c(1969, 1970)) %>%
group_by(year) %>%
summarise(percentile_20 = percentile_cont(weight_pounds, 0.2))
我收到以下错误:
Error: Analytic function PERCENTILE_CONT cannot be called without an OVER clause at [1:16] [invalidQuery]
但是,不清楚如何在此处包含 OVER 子句。如何使用 dplyr 语法获得第 20 个百分位数?