[R] creating a "report" table from a set of lists
Jeff D. Hamann
jeff.hamann at forestinformatics.com
Thu Nov 13 21:48:09 CET 2003
I've been trying to figure out how to accomplish the following...
I've got a list (returned from a function) and I would like to "cbind()" the
lists together to create a "cross tab" report or simply bind them together
somehow
the function returns a list that looks like the following:
> all$BM
$species
[1] "BM"
$vbar.nobs
[1] 3
$vbar.sum
[1] 54.05435
$count.nobs
[1] 20
$basal.area
[1] 26
$expf
[1] 5.339182
>
so there are different variable types in the list (meaning I can't use
cbind?) to create a table with more than one column for stringing together
multiple species. I tried to use rbind and got similar results. Tried
unlist, but the values get cast into strings (which would be alright be
simply reporting values, but I would like to maintain the types (for using
digits=xxx arguments). I've used unlist and rbind, then turn the matrix to
obtain,
> t(rpt)
BM DF
species "BM" "DF"
vbar.nobs "3" "33"
vbar.pctse "8.77458627230236" "2.67841483098916"
count.nobs "20" "20"
count.se "0.254175654140783" "0.630267278307595"
...blah, blah, blah....
count.pctse "39.1039467908896" "8.34791097096152"
combined.pctse "40.0763274125113" "8.76707041068808"
basal.area "26" "302"
expf "5.33918184530697" "48.4101260565985"
>
which is the desired result, but without the quotes
> print.matrix( t(rpt), quote=F )
BM DF
species BM DF
vbar.nobs 3 33
vbar.sum 54.0543454534738 584.712753385096
count.nobs 20 20
count.sum 13 151
...blah, blah, blah....
basal.area 26 302
expf 5.33918184530697 48.4101260565985
volume 100 100
but would still like to be able to control the number of digits that are
printed for the doubles....
Am I even close, or is there more engineering I need to do here?
Thanks,
Jeff.
---
Jeff D. Hamann
Forest Informatics, Inc.
PO Box 1421
Corvallis, Oregon USA 97339-1421
(office) 541-754-1428
(cell) 541-740-5988
jeff.hamann at forestinformatics.com
www.forestinformatics.com
More information about the R-help
mailing list