[R] How to detect which function is used for e.g. printing an object of a given class

Søren Højsgaard Soren.Hojsgaard at agrsci.dk
Wed Sep 24 10:14:43 CEST 2003


Dear all,
I take a an object of class loglm and specialize it into class c("hllm", "loglm"). I would like to define print.hllm such that it prints some special information for the hllm object but ALSO prints the loglm-information using the print method for loglm. There is no print.loglm method (available), but if I look in the src for the MASS library, the function is there. 

Is there a way of seeing exactly which method (function) is used for say printing an object of a given class?

To acomplish what I describe above I define
print.hllm <- function(x, dots){
  < do something special >
  class(x) <- "loglm"
  print(x)
}

Is there an alternative way of "dispatching" the printing, such that the usual print method for loglm is used after doing what is special for hllm?

Thanks in advance
Søren Højsgaard


==========================================
Søren Højsgaard,  PhD, Senior Scientist
Biometry Research Unit
Danish Institute of Agricultural Sciences
Research Centre Foulum, DK-8830 Tjele, Denmark
Phone: +45 8999 1703
E-mail : sorenh at agrsci.dk
Homepage : http://www.jbs.agrsci.dk/~sorenh/




More information about the R-help mailing list