I'm trying to create a method for my class, which inherits from data.frame. I was originally hoping just to inherit the 'show' method from data.frame as well, but I'm also fine with writing my own. I defined my class and 'show' method as follows:
setClass("SCvec", representation(auth = "character", dev = "character", sensor = "character", channel = "character", starttime = "character", endtime = "character"), contains="data.frame") setMethod("show", signature(x="SCvec"), function(x) print(x))
when I type
show in the R console, it prints out:
standardGeneric for "show" defined from package "methods"
function (object) standardGeneric("show") <bytecode: 0x0396bee8> <environment: 0x0393ab60> Methods may be defined for arguments: object Use showMethods("show") for currently available ones. (This generic function excludes non-simple inheritance; see ?setIs)
So it sure looks like I don't need to turn it into a generic using StandardGeneric() myself. but when I run my
setMethod("show", signature(x="SCvec"), function(x) print(x)) line, I get the error
Error in match.call(definition, call, expand.dots) : unused argument(s) (x = c("SCvec", ""))
I've defined this method just like I would define any other one. Why does this method definition not work? Is 'show' different than other generic functions?