[R-pkg-devel] S3 method, useMethod and <-, using Roxygen

Daniel Lüdecke d.luedecke at uke.de
Fri Oct 23 10:30:56 CEST 2015


Hello,
I don't exactly know how to name my problem, so I try to describe it.

In my package (sjmisc), I have a function to set label attributes to 
vectors:

set_labels <- function(x, labels, ...) {
...
}

Usage would be:
x <- set_labels(x, c("lo", "high"))


No I wanted to also add functionality to directly change a value:
set_labels(x) <- c("lo", "high")


So I added this to my package source:

#' @rdname set_labels
#' @export
`set_labels<-` <- function(x, force.labels = FALSE, force.values = TRUE, 
value) {
   UseMethod("set_labels<-")
}

#' @rdname set_labels
#' @export
`set_labels<-.default` <- function(x, force.labels = FALSE, force.values 
= TRUE, value) {
   x <- set_labels(x, values, force.labels, force.values)
   x
}


However, running the check gives following note and warnings:

* checking R code for possible problems ... NOTE
set_labels<-.default: no visible binding for global variable 'values'
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd line widths ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... WARNING
Functions or methods with usage in documentation object 'set_labels' but 
not in code:
   set_labels.default

* checking Rd \usage sections ... WARNING
Objects in \usage without \alias in documentation object 'set_labels':
   'set_labels.default'

Bad \usage lines found in documentation object 'set_labels':
     <- 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.
See chapter 'Writing R documentation files' in the 'Writing R
Extensions' manual.


I don't know what to do here. Any help is appreciated!

Thanks in advance
Daniel
--

_____________________________________________________________________

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Burkhard Göke (Vorsitzender), Prof. Dr. Dr. Uwe Koch-Gromus, Joachim Prölß, Rainer Schoppik
_____________________________________________________________________

SAVE PAPER - THINK BEFORE PRINTING


More information about the R-package-devel mailing list