[R] Possible to pretty-printing using str()?
Janko Thyson
janko.thyson at ku-eichstaett.de
Tue Nov 23 20:32:21 CET 2010
Dear list,
I'm looking for a suitable way to sort of "one-line-pretty-print" an
arbitrary R object in some of my log outputs.
Consider this:
cat(paste("The object/value is: ", x, ".", sep=""), sep="\n")
No problem if x is of class:
- character (length=1)
- numeric (length=1)
- logical (length=1)
For lengths > 1 I can get around by paste(x, collapse=my.delimiter). So:
cat(paste("The object/value is: ", paste(x, collapse=my.delimiter), ".",
sep=""), sep="\n")
"Problem" if x is of class
- data.frame
- matrix
- list
- other complex objects
For those objects something like the output of str() arranged in one line of
class 'character' would be great.
Is that possible somehow?
Thanks for any comments,
Janko
########## SYSTEM INFO ##########
Windows XP SP3
R 2.12.0 (patched as of 2010-11-22)
Eclipse 3.6.1 (Helios)
StatET 0.9.x
###############################
More information about the R-help
mailing list