如何查看`dplyr :: collect`方法的帮助? [英] How do I see the help for the `dplyr::collect` method?
问题描述
我正在尝试找出哪些附加参数可以传递给省略号 ... $ c $中的
dplyr :: collect
C>。我想这样做,因为我相信收集
的行为已经在 dplyr
版本 0.4.3
和 0.5
。似乎在新版本 collect()
只下载前100k行,除非新的 n = Inf
参数
我已经使用以下方式检索与 collect
相关联的方法:
>方法('collect')
/ pre>
[1] collect.data.frame * collect.tbl_sql *
参见'?方法'来访问帮助和源代码
我查看了S3
方法的帮助文件
,但无法解决如何获取帮助文件code> collect.tbl_sql ,作为?dplyr :: collect.tbl_sql
不起作用。解决方案
- 星号/ code>表示每个方法都不从
dplyr
中导出,命名空间
- 要访问帮助文件,需要使用三个冒号,即
?dplyr ::: collect.tbl_sql
/ li>
- 然而,这些方法没有帮助文件,所以我们需要检查源代码来查看每个版本中的这些功能的行为。
在
0.4.3
通过在 tbl-sqr.r 文件.4.3.tar.gzrel =nofollow noreferrer>源代码:collect.tbl_sql< - function(x,...){
grouping_df(x $ query $ fetch(),groups(x))
}
和
0.5
:> dplyr ::: collect.tbl_sql
函数(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)
}
grouping_df(out,groups(x))
}
因此,我们可以得出结论,
收集
的行为确实以我的问题最初描述的方式发生了变化。I am trying to find out what additional arguments can be passed to
dplyr::collect
in the ellipsis...
. I want to do this because I believe that the behaviour ofcollect
has changed betweendplyr
version0.4.3
and0.5
. It seems that in the new versioncollect()
only downloads the first 100k rows, unless a newn = Inf
argument is passed.I have retrieved the methods associated with
collect
using:> methods('collect') [1] collect.data.frame* collect.tbl_sql* see '?methods' for accessing help and source code
I have looked at the help file for S3
methods
but cannot work out how to get help oncollect.tbl_sql
, as?"dplyr::collect.tbl_sql"
does not work.解决方案As noted by Chrisss and Zheyuan Li:
- The asterisk/star/* next to the method name after running
methods
indicates that each of these methods are not exported from thedplyr
namespace.- To access the helpfile, one then needs to use three colons, i.e.,
?dplyr:::collect.tbl_sql
- However, there is no helpfile for these methods, so we need to examine the source code to look at the behaviour of each of these functions in the respective versions.
In
0.4.3
by examiningtbl-sqr.r
file in the source code:collect.tbl_sql <- function(x, ...) { grouped_df(x$query$fetch(), groups(x)) }
and in
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)) }
Thus, we can conclude that the behaviour of
collect
has indeed changed in the manner originally described in my question.这篇关于如何查看`dplyr :: collect`方法的帮助?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!