我想在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)
但他们没有工作。任何的想法? 非常感谢提前。 最好的,马克
答案 0 :(得分:2)
尝试
\S4method{timestamps}{.MoveTrack}(this) <- value
将第二个{}中的多个调度作为逗号分隔列表。