0

When I dispatch on the top level object, all the functions export to the namespace. Everything works as I would expect it to.

myfun <- function(obj) {
   UseMethod("myfun",obj) 
}

#' @export
myfun.this <- function()

Namespace:

S3Method(myfun,this)
export(myfun)

BUT, when I try to dispatch on an element within my object...

#' Subsets recoded data by a condition
#' 
#' This function filters a list, data.frame or vector by a condition
#' 
#' @param so A surv3 object
#' @param condition A positively stated condition or logical vector
#' @export 
subset.surv3 <- function(so, condition) { 
  UseMethod("subset.surv3",so$recoded) # THIS PART
}

#' @export
subset.surv3.categorical <- function(so, condition) {
  ....
  return(so)
}

#' @export
subset.surv3.continuous <- function(so, condition) {
  ...
  return(so)
}

Namespace:

S3method(subset,surv3.categorical)
S3method(subset,surv3.continuous)

However, the functions are not exported.

I would have expected:

export(subset.surv3.categorical)
export(subset.surv3.continuous)

What am I doing wrong?

Brandon Bertelsen
  • 43,807
  • 34
  • 160
  • 255

1 Answers1

0

I post something similar here:

But, after all, S3 dispatching should pass thru generic function:

  • the generic could "wrap" method call
  • the S3 object could have classes in higher priority.

This should work without "explicit" method export.

Community
  • 1
  • 1
hute37
  • 197
  • 2
  • 8