I have a function that does nothing more than ads a unique attr
to any R object. Base demo:
#' Setter function
#' @param x an R object
#' @param value a character value to set
#' @export
`foo<-` <- function(x, value){
attr(x, 'foo') <- value
return(x)
}
This works like a charm except for generating a good Rd file, relevant part:
\usage{
foo(var, value) <- value
}
And of course it triggers a warning while running R CMD check
as it should be foo(var) <- value
.
Any hints would be really apprecieted!
Update: thanks to richierocks it seems there is a fix
R objects are documented in files written in “R documentation” (Rd) format, a simple markup language much of which closely resembles (La)TeX, which can be processed into a variety of formats, including LaTeX, HTML and plain text.
To add documentation to an R package, you need to create a subdirectory “ man ” containing a set of files, one per function, in a special R Documentation format ( . Rd ). These will be the source for the documentation for each function; R processes them to create plain text, PDF, and HTML versions.
You can use the roxygen tag @usage
Here is an example from one of my packages:
#' @rdname pattern
#' @usage pattern(x) <- value
#' @param value New value
#' @export pattern<-
"pattern<-" <- function(x, value=c("^", "($|(_\\d+(_\\d+)*)$)")){
attr(x, "pattern") <- value
x
}
This results in my desired documentation:
Usage
pattern(x) <- value
Arguments
x surveydata object
value New value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With