[R] How to latex tables?
steve
fisk at bowdoin.edu
Sat May 5 15:43:50 CEST 2007
Suppose I have a table constructed from structable or simply just an
object of class table. How can I convert it to a latex object? I looked
in RSiteSearch, but only found info about matrices or data frames.
Steve
For example, here is a table t2
> str(t2)
table [1:2, 1:2, 1:2] 6 8 594 592 57 ...
- attr(*, "dimnames")=List of 3
..$ Hospital : chr [1:2] "A" "B"
..$ Survival : chr [1:2] "Died" "Survived"
..$ Condition: chr [1:2] "Good" "Poor"
Here's what happens with latex(t2):
latex(t2)
Error in x[, j] : incorrect number of dimensions
Next, here's what happens with a structtable.
> tab=structable(Hospital ~ Condition + Survival, data=t2)
> tab
Hospital A B
Condition Survival
Good Died 6 8
Survived 594 592
Poor Died 57 8
Survived 1443 192
If I use latex(tab) I get
Error in dimnames(cx) <- list(rnam, nam) :
length of 'dimnames' [1] not equal to array extent
In addition: Warning messages: ...(deleted)...
More information about the R-help
mailing list