I am very stunned to learn that the show is a common S4, and that I cannot find a way to use the S3 manager to make the show function work. Simple demo:
> x <- 1:5 > xx <- structure(x,class="aClass") > show.aClass <- function(object){ + cat("S3 dispatching.\n") + print(object) + } > xx [1] 1 2 3 4 5
No sending S3 here ...
> setMethod("show","aClass",function(object){ + cat("S4 dispatching.\n") + print(object) + }) in method for 'show' with signature '"aClass"': no definition for class "aClass" [1] "show" > xx [1] 1 2 3 4 5
What do you think?
> print.aClass <- function(object){ + cat("the print way...\n") + print(as.vector(object))
And for print it works.
I have pretty good reasons to stay with S3 (most of which is to minimize overhead, since the objects will be widely used at boot). How can I define another show and print method here?
source share