Last data update: 2014.03.03

R: Pretty-print the Structure of a Data Object
list.treeR Documentation

Pretty-print the Structure of a Data Object

Description

This is a function to pretty-print the structure of any data object (usually a list). It is similar to the R function str.

Usage

list.tree(struct, depth=-1, numbers=FALSE, maxlen=22, maxcomp=12, 
          attr.print=TRUE, front="", fill=". ", name.of, size=TRUE)

Arguments

struct

The object to be displayed

depth

Maximum depth of recursion (of lists within lists ...) to be printed; negative value means no limit on depth.

numbers

If TRUE, use numbers in leader instead of dots to represent position in structure.

maxlen

Approximate maximum length (in characters) allowed on each line to give the first few values of a vector. maxlen=0 suppresses printing any values.

maxcomp

Maximum number of components of any list that will be described.

attr.print

Logical flag, determining whether a description of attributes will be printed.

front

Front material of a line, for internal use.

fill

Fill character used for each level of indentation.

name.of

Name of object, for internal use (deparsed version of struct by default).

size

Logical flag, should the size of the object in bytes be printed?

A description of the structure of struct will be printed in outline form, with indentation for each level of recursion, showing the internal storage mode, length, class(es) if any, attributes, and first few elements of each data vector. By default each level of list recursion is indicated by a "." and attributes by "A".

Author(s)

Alan Zaslavsky, zaslavsk@hcp.med.harvard.edu

See Also

str

Examples

X <- list(a=ordered(c(1:30,30:1)),b=c("Rick","John","Allan"),
          c=diag(300),e=cbind(p=1008:1019,q=4))
list.tree(X)
# In R you can say str(X)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Hmisc)
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package: 'Hmisc'

The following objects are masked from 'package:base':

    format.pval, round.POSIXt, trunc.POSIXt, units

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Hmisc/list.tree.Rd_%03d_medium.png", width=480, height=480)
> ### Name: list.tree
> ### Title: Pretty-print the Structure of a Data Object
> ### Aliases: list.tree
> ### Keywords: documentation
> 
> ### ** Examples
> 
> X <- list(a=ordered(c(1:30,30:1)),b=c("Rick","John","Allan"),
+           c=diag(300),e=cbind(p=1008:1019,q=4))
> list.tree(X)
 X = list 4 (723952 bytes)
.  a = integer 60= factor (30 levels)( ordered factor )= 1 2 3 4 5 6 7 8 ...
.  b = character 3= Rick John Allan 
.  c = double 90000= array 300 X 300= 1 0 0 0 0 0 0 0 ...
.  e = double 24= named array 12 X 2= 1008 1009 1010 1011 ...
> # In R you can say str(X)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>