[R] separate and arrange outputs

Jerome Asselin jerome.asselin.stat at gmail.com
Tue Apr 26 22:06:13 CEST 2011


On Tue, 2011-04-26 at 19:46 +0200, ivan wrote:
> Hello,
> 
> given that a self made function produces multiple outputs, is there a
> possibility to separate latter by stars or simply by blank lines? Are there
> funtions for the arrangement of the output in general?

You can create a class for your object and then write a "print" method.

Example:

a <- list(a=2, b=c(2,2,2))
class(a) <- "myclass"
print.myclass <- function(x)
{
  print(x[[1]])
  cat("***********\n")
  print(x[[2]])
}

This yields:

> a
[1] 2
***********
[1] 2 2 2

HTH,

Jerome



More information about the R-help mailing list