gpt4 book ai didi

r - 链接到 .rd 文件中的 S4 方法?

转载 作者:行者123 更新时间:2023-12-03 20:30:01 25 4
gpt4 key购买 nike

我正在编写一个带有 S4 类的包,并且我已经为 as.POSIXct 编写了方法和 as.POSIXlt为类(class)。我已经写了文档,一切看起来都很好,只是我想引用 as.POSIXct as.POSIXlt 文档中的方法,反之亦然。我试过 \S4method{coerce}{abc, POSIXct}(from, to) , (其中 'abc' 是 S4 类),但这只能放在 \usage 中部分,这不是我想要的地方。有没有办法做到这一点?对我来说,它不被允许似乎很奇怪。

我意识到可以组合这些 .rd 文件并避免这个问题,但我正在尝试尽可能多地了解 R 中的类和包,所以无论如何这对我很感兴趣。

这是 .Rd 文件之一的骨架:

\name{as.POSIXct-methods}
\docType{methods}
\alias{as.POSIXct-methods}
\alias{as.POSIXct,ANY-method}
\alias{as.POSIXct,abc-method}
\title{\code{abc} Method for Function \code{as.POSIXct}}
\description{
\code{as.POSIXct} method to coerce timestamps in \code{abc} objects into
\code{POSIXct} format.
}
\section{Methods}{
\describe{
~~description here~~

\item{\code{signature(x = "ANY")}}{
default implementation (from base)
}

\item{\code{signature(x = "abc")}}{
implementation for \code{\link{abc}} objects.
~~more description of function~~
See \code{\linkS4class{abc}} for more about abc objects.
See also \code{\link[abc]{as.POSIXlt}} for the corresponding \code{POSIXlt} method.
}
}}
\keyword{methods}

倒数第四行是导致问题的那一行。

最佳答案

Cross-references section编写 R 扩展,您可以创建指向其他帮助页面的链接,如下所示:

\code{\link[base]{as.POSIXct}}

其中“base”是包的名称(我不认为 [base] 是必​​要的,但如果它是另一个包,那就是)

关于r - 链接到 .rd 文件中的 S4 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12043765/

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