2

我想在 R 中记录一个替换函数,但是当我运行 R CMD 检查时,我收到以下错误消息:

Bad \usage lines found in documentation object 'timestamps':
  <unescaped bksl>S4method{"timestamps<-"}{.MoveTrack}(this, value)

Functions with \usage entries need to have the appropriate \alias
entries, and all their arguments documented.
The \usage entries must correspond to syntactically valid R code.

文档如下所示:

\name{timestamps}

\alias{timestamps}
\alias{timestamps,.MoveTrack-method}
\alias{timestamps,.MoveTrackSingle-method}
\alias{"timestamps<-",.MoveTrack-method}

\docType{methods}

\title{Extract the timestamps of a Move or MoveStack object}

\description{The timestmaps method returns or sets the timestamps of a track from a Move or MovesStack object.}

\usage{
\S4method{timestamps}{.MoveTrackSingle}(this)
\S4method{timestamps}{.MoveTrack}(this)
\S4method{"timestamps<-"}{.MoveTrack}(this, value)
}

\arguments{
  \item{this}{Move or MoveStack object}
  \item{value}{timestamps from class POSIXct}
}

实际功能如下:

setGeneric("timestamps", function(this) standardGeneric("timestamps"))
setMethod("timestamps", ".MoveTrack",
   function(this) {
      this@timestamps
   })

setMethod("timestamps", ".MoveTrackSingle",
          function(this) {
            this@timestamps
          })

setGeneric("timestamps<-", function(this, value) standardGeneric("timestamps<-"))
setReplaceMethod("timestamps", ".MoveTrack",
   function(this, value) {
      this@timestamps <- value
      this
   })

我搜索了错误消息,但我发现的只是 Roxygen 文档,这对我没有帮助。我还尝试了不同的文档样式,例如:

\S4method{"timestamps<-"}{.MoveTrack}(this, value)
\S4method{"timestamps<-."}{.MoveTrack}(this, value)
\S4method{"timestamps<-$"}{.MoveTrack}(this, value)
\S4method{'timestamps<-'}{.MoveTrack}(this, value)
\S4method{timestamps<-}{.MoveTrack}(this, value)
\S4method{"timestamps\<\-"}{.MoveTrack}(this, value)
\S4method{"timestamps\\<\\-"}{.MoveTrack}(this, value)

但他们都没有工作。任何的想法?提前非常感谢。最好的,马可

4

1 回答 1

2

尝试

\S4method{timestamps}{.MoveTrack}(this) <- value

在第二个 {} 中以逗号分隔列表的形式进行多次调度。

于 2012-08-14T13:06:49.420 回答