Square bracket documentation `` `function

I have a function in R that looks something like this:

setMethod('[', signature(x="stack"),definition=function(x,i,j,drop){ new('class', as(x, "SpatialPointsDataFrame")[i,]) }) 

I use it to get one element from a complex object. For the package I am creating, I need a .Rd file to document the function. I saved it as [.Rd, but somehow the CMD R check does not see this. It returns:

 Undocumented S4 methods: generic '[' and siglist 'MoveStack,ANY,ANY' 

The [.Rd begins with these lines:

 \name{[} \alias{[} \alias{[,stack,ANY,ANY-method} \docType{methods} \title{Returns an object from a stack} \description{Returning a single object} \usage{ \S4method{\[}{stack,ANY,ANY}(x,i,y,drop) } 

Any idea how I can check the r cmd of this file?

+4
source share
1 answer

If you look at the source code for the sp package, for example SpatialPolygons-class.Rd , section Methods:

 \section{Methods}{ Methods defined with class "SpatialPolygons" in the signature: \describe{ \item{[}{\code{signature(obj = "SpatialPolygons")}: select subset of (sets of) polygons; NAs are not permitted in the row index} \item{plot}{\code{signature(x = "SpatialPolygons", y = "missing")}: plot polygons in SpatialPolygons object} \item{summary}{\code{signature(object = "SpatialPolygons")}: summarize object} \item{rbind}{\code{signature(object = "SpatialPolygons")}: rbind-like method} } } 

for [ .

File Name and Class

 \name{SpatialPolygons-class} \alias{[,SpatialPolygons-method} 

If you look at the help page for ?SpatialPolygons , you should see

 > Methods > > Methods defined with class "SpatialPolygons" in the signature: > > [ signature(obj = "SpatialPolygons"): select subset of (sets of) > polygons; NAs are not permitted in the row index > 

So, I would venture to suggest that if you provide the correct name for the ASCII name, give it an alias, as in the above example, you should be fine.

+3
source

All Articles