On Fri, 27 Jul 2018, William Dunlap wrote:

I often use capture.output to slightly reformat printout output.  E.g, to
indent str's output to make it easier to read debugging printouts:
debug_print <- function(x, name=substitute(x), indent=4)
{
  cat(sep="\n", name, paste0(strrep(" ", indent), capture.output(str(x))))
}
Used as in
myData <- list(One=1:100,Two=log2(1:5))
debug_print(myData)
myData
   List of 2
    $ One: int [1:100] 1 2 3 4 5 6 7 8 9 10 ...
    $ Two: num [1:5] 0 1 1.58 2 2.32

Bill,

  This is good to know.

Many thanks,

Rich

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to