r - <unescaped bksl>S4method 记录替换函数时出错

标签 r function namespaces documentation

我想在 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)

但它们都不起作用。任何想法? 预先非常感谢。 最好的,马可

最佳答案

尝试

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

在第二个{}中使用多个分派(dispatch)作为逗号分隔列表。

关于r - <unescaped bksl>S4method 记录替换函数时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11952842/

相关文章:

c# - 命名空间不存在

arrays - 从数组中提取数组

r - 在 data.table 上使用 geosphere distm 函数来计算距离

r - 将一列列表强制转换为 R 数据框中的字符串

jquery - 如何使用 jquery .mouseleave 事件调用函数

Excel VBA 函数根据范围内的单元格背景颜色返回 True 或 False

javascript - Onkeydown JS函数添加调用相同函数的输入

r - do.call() 不喜欢带有列表的基函数 "c"

javascript - 请解释 jQuery-ui 项目中的这些行 - 与添加 "sub-plugins"有关

c# - Unity + Leap Motion : error CS0246 (namespace) issue