Hello,
?as.character says that the as.character function is a generic with
usage: as.character(x, ...). So, I want to create an S4 object with an
as.character method following the above usage, but I get the below error
telling me that ... isn't in the generic for as.character.
setClass("tmp", "numeric")
setMethod("as.character", "tmp", function(x, ...) paste(x, c(...)))
Error in rematchDefinition(definition, fdef, mnames, fnames, signature)
:
Methods can add arguments to the generic only if "..." is an
argument to the generic
Am I reading the documentation incorrectly? How do I correctly pass the
... object to the method for this "tmp" object?
However I note that looking at the generic function, I see no mention of
... (despite the documentation).
getGeneric("as.character")
standardGeneric for "as.character" defined from package "base"
function (x)
standardGeneric("as.character", .Primitive("as.character"))
<environment: 0145EDC4>
Methods may be defined for arguments: x
So, briefly, is the documentation wrong? Am I doing something wrong? Can
I create an as.character method and pass additional arguments to it as I
think I should be able to?