[R] Multiple outputs of a function
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Oct 19 10:05:23 CEST 2000
On Thu, 19 Oct 2000, isabelle Zabalza-Mezghani wrote:
> Hello everybody,
> I'm writting some functions for experimental designs. The one I'm
> working on is similar to "fac.design" on Splus.
> The problem I have is with the form of the output :
> When the argument fraction is submitted, Splus gives something like :
> A B C
> 1 - - -
> 2 + + -
> 3 + - +
> 4 - + +
> Fraction : ~A:B:C
> The first part of this output is the design, and the second part is the
> formula which allows to fractionate the full design. This output isn't a
> My problem is the following :
> I can't manage to obtain such a composite output. The lonely way I've
> already found is to use :
> cat("Fraction: ")
> This solution is only suitable for an output on screen, but it reveals
> bad as soon as I assign this function
> to an object (for ex: tmp <- fac.design( ....) ) since only the last
> command I performed (here print(attr(design,"fraction")))
> is assigned to my object tmp.
> I hope someone can help me ...
It's done via classes. fac.design returns an object of class c("design",
"data.frame"), and that is printed by the method print.design for the
generic function print. To see how this might be done in R, look at
print.Anova in package MASS.
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help