>>>>> "vincent" == vincent <[EMAIL PROTECTED]> >>>>> on Mon, 19 Jun 2006 16:30:54 +0200 writes:
vincent> Gabor Grothendieck a écrit : >> Perhaps you what you want to do is to return an object >> that has a print method like this: >> f1 <- function(x) structure(c(x, x^2), class = "f1") >> print.f1 <- function(x) cat("x is", x[1], "x squared is", x[2], "\n") vincent> Thank you Gabor for this idea. Unfortunately, it's not a good idea inspite of coming from Gabor who has donated many very good ideas to R-help: help(print) tells you >> 'print' prints its argument and returns it _invisibly_ (via >> 'invisible(x)'). It is a generic function which means that new >> printing methods can be easily added for new 'class'es. I.e., as a good Ritizen, Gabor's function above should **REALLY** be print.f1 <- function(x) { cat("x is", x[1], "x squared is", x[2], "\n") invisible(x) } Martin Maechler, ETH Zurich ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html