Using the colwise () method within an S3 method

I have a function shift

defined as:

require(plyr)
shift <- function(x,...) {
    UseMethod("shift",x)
}
shift.default <- function(x,n=1,wrap=TRUE,pad=FALSE,...) {
    # innards
    return(0)
}
shift.data.frame <- colwise(shift.default)

      

It works fine until I put it in a package and try it R CMD check

. Then I get a warning while checking the S3 generic / method consistency check. He reports that shift.data.frame and shift disagree:

shift(x,...)
shift.data.frame(df,...)

      

I am assuming that these results are from x

and are df

not the same. Any convenient way to fix this?

+3


source to share


1 answer


Does something like this work?



shift.data.frame <- function(x, ...) {
  colwiseShift <- colwise(shift.default)
  colwiseShift(x, ...)
}

      

+2


source







All Articles