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

Liz*_*der 5 r package generic-method r-s4

我正在编写一个包含 S4 类的包,并且我已经为该类编写了as.POSIXct方法as.POSIXlt。我已经编写了文档,一切看起来都很好,除了我想引用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}
Run Code Online (Sandbox Code Playgroud)

倒数第四行是引起问题的行。

Mar*_*gan 3

链接的基本格式是

\link{foo}
Run Code Online (Sandbox Code Playgroud)

其中foo在某些帮助页面(在同一包中)中显示为\alias{foo}. 因此,如果您的其他包有 \alias{as.POSIXlt,abc-method} (注意没有空格)那么

\link{as.POSIXlt,abc-method}
Run Code Online (Sandbox Code Playgroud)

仅当链接到其他包时才需要添加[abc],这样语义就会令人困惑(在 中\link[abc]{foo},foo 是HTML 帮助页面的名称,而不是别名)。添加\code{}是标记,因此与建立链接没有直接关系。上面的链接将“as.POSIXlt,abc-method”插入到帮助页面中,这可能比可能存在的任意 \alias 标签提供更多信息(或不提供更多信息)。