gpt4 book ai didi

r - S4method 记录替换函数时出错

转载 作者:行者123 更新时间:2023-12-04 16:51:32 27 4
gpt4 key购买 nike

我想记录 R 中的替换函数,但是当我运行 R CMD check 时,我收到此错误消息:

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com