【发布时间】:2012-08-20 19:20:38
【问题描述】:
我正在编写一个带有 S4 类的包,并且我已经为该类编写了 as.POSIXct 和 as.POSIXlt 的方法。我已经编写了文档,一切看起来都很好,除了我想在as.POSIXlt 的文档中引用as.POSIXct 方法,反之亦然。我尝试了\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}
倒数第四行是引起问题的那一行。
【问题讨论】:
标签: r package s4 generic-method