我试图找出可以将哪些附加参数传递给 dplyr::collect
在省略号中 ...
.我想这样做是因为我相信 collect
的行为在dplyr
之间发生了变化版本0.4.3
和 0.5
.好像在新版本collect()
只下载前 100k 行,除非新的 n = Inf
参数通过。
我已检索到与 collect
相关的方法使用:
> methods('collect')
[1] collect.data.frame* collect.tbl_sql*
see '?methods' for accessing help and source code
我查看了 S3 的帮助文件
methods
但不知道如何在 collect.tbl_sql
上获得帮助, 如 ?"dplyr::collect.tbl_sql"
不起作用。
最佳答案
正如 Chrisss 所指出的和 Zheyuan Li :
methods
表示这些方法中的每一个都不是从 dplyr
导出的命名空间。 ?dplyr:::collect.tbl_sql
在
0.4.3
通过检查 tbl-sqr.r
source code 中的文件:collect.tbl_sql <- function(x, ...) {
grouped_df(x$query$fetch(), groups(x))
}
并在
0.5
:> dplyr:::collect.tbl_sql
function (x, ..., n = 1e+05, warn_incomplete = TRUE)
{
assert_that(length(n) == 1, n > 0L)
if (n == Inf) {
n <- -1
}
sql <- sql_render(x)
res <- dbSendQuery(x$src$con, sql)
on.exit(dbClearResult(res))
out <- dbFetch(res, n)
if (warn_incomplete) {
res_warn_incomplete(res, "n = Inf")
}
grouped_df(out, groups(x))
}
因此,我们可以得出结论
collect
的行为确实以我的问题中最初描述的方式发生了变化。
关于r - 如何查看 `dplyr::collect` 方法的帮助?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39714170/