Marco Smolla
Marco Smolla

Reputation: 188

<unescaped bksl>S4method Error when documenting a replacement function

I want to document a replacement function in R, but when I run R CMD check I get this error message:

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.

the documentation looks like this:

\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}
}

and the actual function is the following:

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
   })

I searched for the error message but all I found was about Roxygen documentation which didn't help me. I also tried different documentation styles like :

\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)

but non of them worked. Any idea? Thanks a lot in advance. best, marco

Upvotes: 2

Views: 261

Answers (1)

Martin Morgan
Martin Morgan

Reputation: 46856

Try

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

with multiple dispatch in the second{} as a comma-separate list.

Upvotes: 2

Related Questions