gpt4 book ai didi

r - 如何使用roxygen正确记录S4 “[”和“[<-”方法?

转载 作者:行者123 更新时间:2023-12-03 12:13:49 26 4
gpt4 key购买 nike

在下面,我发布了一个迷你示例,其中我想为该示例编写文档
S4类的“[“方法。有人知道如何使用roxygen和S4正确记录通用"["的方法吗?
构建后检查软件包时会收到警告(请参阅下文)。

#' An S4 class that stores a string.
#' @slot a contains a string
#' @export
setClass("testClass",
representation(a="character"))

#' extract method for testClass
#'
#' @docType methods
#' @rdname extract-methods
setMethod("[", signature(x = "testClass", i = "ANY", j="ANY"),
function (x, i, j, ..., drop){
print("void function")
}
)

包裹检查摘录:
* checking for missing documentation entries ... WARNING
Undocumented S4 methods:
generic '[' and siglist 'testClass'
All user-level objects in a package (including S4 classes and methods)
should have documentation entries.
See the chapter 'Writing R documentation files' in manual 'Writing R Extensions'.

最佳答案

从roxygen2> 3.0.0开始,您不再需要变通方法,而仅需要:

#' Extract parts of testClass.
#'
setMethod("[", signature(x = "testClass", i = "ANY", j="ANY"),
function (x, i, j, ..., drop){
print("void function")
}
)

关于r - 如何使用roxygen正确记录S4 “[”和“[<-”方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4396768/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com