Passing variables declared in generics across methods

Consider the following S3 class:

stuff <- function(x, y) {
  this <- x[[1]]
  UseMethod("stuff")
}

stuff.foo <- function(x, y) {
  this %in% y
}

stuff.bar <- function(x, y) {
  names(this) %in% y
}

R CMD check complains that there is no visible binding for global variable ‘this’.

Is there a way to pass this across methods without making R unhappy and without declaring this in the global environment?

I think you can put utils::globalVariables("this") in your package, see the manual for details and CRAN packages for examples: Sign in to GitHub · GitHub

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.