# 'tli_xtab' is an 'xtable' object created using 'xtable::xtable':
class(tli_xtab)
# This package provides a 'textTable' method for such objects:
ttbl <- textTable(tli_xtab)
plot(ttbl)
if (requireNamespace("xtable", quietly=TRUE)) withAutoprint({
data(tli, package="xtable")
# ANOVA table.
fm1 <- aov(tlimth ~ sex + ethnicty + grade + disadvg, data = tli)
plt1 <- plot(textTable(fm1.table <- xtable::xtable(fm1),
title="xtable: ANOVA table"))
# Table of linear regression results.
fm2 <- lm(tlimth ~ sex*ethnicty, data = tli)
plt2 <- plot(textTable(fm2.table <- xtable::xtable(fm2),
title="xtable: Linear regression"))
# Time series table.
temp.ts <- ts(cumsum(1 + round(rnorm(100), 0)), start = c(1954, 7),
frequency = 12)
plt3 <- plot(textTable(xtable::xtable(temp.ts, digits = 0),
title="xtable: Time series"))
# Math style for scientific notation.
plt4 <- plot(textTable(xtable::xtable(data.frame(text = c("foo","bar"),
googols = c(10e10,50e10),
small = c(8e-24,7e-5),
row.names = c("A","B")),
display = c("s","s","g","g")),
mathExponents = TRUE,
title=c("xtable:", "Math style for scientific notation")))
print(plt1, position=c(0.1, 0.9))
print(plt2, position=c(0.1, 0.5), newpage=FALSE)
print(plt3, position=c(0.1, 0.1), newpage=FALSE)
print(plt4, position=c(0.9, 0.9), newpage=FALSE)
# By default vertical rules specified by '|' characters in 'align' are
# ignored. They can be added afterward using the 'addHvrule' function
# as follows:
tli.table <- xtable::xtable(tli[1:10, ])
xtable::align(tli.table) <- "|rrl|l|lr|"
plt <- plot(textTable(tli.table,
title="xtable: Vertical rules derived from 'align'"))
pipe_posn <- which(unlist(strsplit(attr(tli.table, "align"), "")) == "|")
vrule_acol <- pipe_posn - seq_along(pipe_posn) + 0.5
for (ac in vrule_acol) plt <- addHvrule(plt, direction="vrule", acols=ac,
arows=arow(plt, "colhead_and_body"),
props=element_hvrule(linetype=1,
color="black"))
plt
})
Run the code above in your browser using DataLab