我已经阅读了Roxygen2 PDF以及这个网站,我对@method @ S3method @export和你如何使用它们来正确记录S3方法之间的区别感到迷茫.我
编写了以下示例进行讨论:1.我如何正确记录这些内容?
2.我如何模拟?print和其他通用函数的文档,这些函数显示所有特定于类的实现的用例(即方式?print显示'factor','table','function'的用法)
3.来自wiki页面:"所有导出的方法都需要@ S3method标记.它的格式与@method相同.这会导出方法,而不是函数 - 即泛型(myobject)将起作用,但generic.mymethod(myobject)不会."
我无法解释这一点.这似乎说如果标签指定不正确,函数/方法调用将无法正常工作?具体会打破什么?
MyHappyFunction = function( x , ... )
{
UseMethod( "MyHappyFunction" )
}
MyHappyFunction.lm = function( x , ... )
{
# do some magic
}
Run Code Online (Sandbox Code Playgroud) 我为一个使用S3类的函数创建了一个roxygen文件.我roxygenize然后建立并检查并得到一个警告:
* checking S3 generic/method consistency ... WARNING
common:
function(word.list, ...)
common.list:
function(word.list, overlap, equal.or)
See section 'Generic functions and methods' of the 'Writing R
Extensions' manual.
Run Code Online (Sandbox Code Playgroud)
所以我花时间学习:
http://cran.r-project.org/doc/manuals/R-exts.html#Generic-functions-and-methods & https://github.com/hadley/devtools/wiki/S3
但我无法弄清楚我在下面的文件中做错了什么.该功能按预期工作.
1)为什么会发出警告?2)我怎么能让它消失?
#' Find Common Words Between Groups
#'
#' Find common words between grouping variables (e.g. people).
#'
#' @param word.list A list of names chacter vectors.
#' @param overlap Minimum/exact amount of overlap.
#' @param equal.or A character vector of c(\code{"equal"}, \code{"greater"},
#' \code{"more"}, \code{"less"}).
#' @param …Run Code Online (Sandbox Code Playgroud)