如何查看`dplyr :: collect`方法的帮助? [英] How do I see the help for the `dplyr::collect` method?

查看:82
本文介绍了如何查看`dplyr :: collect`方法的帮助?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出哪些附加参数可以传递给省略号 ... dplyr :: collect C>。我想这样做,因为我相信收集的行为已经在 dplyr 版本 0.4.3 0.5 。似乎在新版本 collect()只下载前100k行,除非新的 n = Inf 参数



我已经使用以下方式检索与 collect 相关联的方法:

 >方法('collect')
[1] collect.data.frame * collect.tbl_sql *
参见'?方法'来访问帮助和源代码
/ pre>

我查看了S3 方法的帮助文件,但无法解决如何获取帮助文件code> collect.tbl_sql ,作为?dplyr :: collect.tbl_sql不起作用。

解决方案

Chrisss 李哲源


  1. 星号/ code>表示每个方法都不从 dplyr 中导出,命名空间

  2. 要访问帮助文件,需要使用三个冒号,即?dplyr ::: collect.tbl_sql / li>
  3. 然而,这些方法没有帮助文件,所以我们需要检查源代码来查看每个版本中的这些功能的行为。

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 of collect has changed between dplyr version 0.4.3 and 0.5. It seems that in the new version collect() only downloads the first 100k rows, unless a new n = 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 on collect.tbl_sql, as ?"dplyr::collect.tbl_sql" does not work.

解决方案

As noted by Chrisss and Zheyuan Li:

  1. The asterisk/star/* next to the method name after running methods indicates that each of these methods are not exported from the dplyr namespace.
  2. To access the helpfile, one then needs to use three colons, i.e., ?dplyr:::collect.tbl_sql
  3. 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 examining tbl-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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆