Description Usage Arguments Author(s) References Examples
Provides a user friendly interface to generation of booktab style tables using xtable.
1 2 |
x |
an object of class 'TableMonster' – see below |
special |
Optionally, one of the following: 'aos' or 'jrss-b', to produce tables compatible with the style guid of the Annals of Statistics or JRSS-B, respectively. |
simple |
Set to 'TRUE' to override the default treatment of multi-level tables |
dbg |
Set to 'TRUE' and the routine will output intermediate results to a file 'debug.rda' containing the computed results of the list 'add.to.row' which is passed to the function print.xtable. |
... |
1. Optionally, |
Grant Izmirlian
<https://www.youtube.com/watch?v=CM1TaNVnh58>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | ## Example 1: A table with a single heading
##
library(TableMonster)
tst <- as.data.frame(cbind(rep(c("John","Joe","Mary","Jane","Alex"), 2),
rep(c("male","male","female","female","female"), 2),
rep(c(12345, 54321, 46943, 23123, 51234), 2)))
hdngs <- as.list(rep("", 3))
names(hdngs) <- c("Name", "Gender", "Student ID")
tmHeadings(tst) <- hdngs
tmCtypes(tst) <- rep("n",3)
tmDigits(tst) <- rep(0,3)
tmCaption(tst) <-"This is JUST a TEST"
class(tst) <- "TableMonster"
tst
print(tst, label="tbl:anexample")
print(tst, include.rownames=FALSE, sanitize.text.function=I)
print(tst, label="tbl:anexample", include.rownames=FALSE, sanitize.text.function=I)
## Example 2: A table with a two level heading
##
library(TableMonster)
gp <- rep(1:2,each=5)
m1 <- rnorm(10)
s1 <- (rchisq(10, df=1)/10)^0.5
z1 <- m1/s1
m2 <- rnorm(10)
s2 <- (rchisq(10, df=1)/10)^0.5
z2 <- m2/s2
m3 <- rnorm(10)
s3 <- (rchisq(10, df=1)/10)^0.5
z3 <- m3/s3
foo <- as.data.frame(list(variable=letters[sample(10)], group=gp, model1=m1, se1=s1, Z1=z1,
model2=m2, se2=s2, Z2=z2,
model3=m3, se3=s3, Z3=z3))
tmHeadings(foo) <- list('Variable'="", 'Group'="",
'Model 1'=list('Estimate'="", 'Std Err'="", 'Wald Test'=""),
'Model 2'=list('Estimate'="", 'Std Err'="", 'Wald Test'=""),
'Model 3'=list('Estimate'="", 'Std Err'="", 'Wald Test'=""))
tmCaption(foo) <- "This is TableMonster (TM)!!!"
tmCtypes(foo) <- c("c","c",rep("n",9))
tmDigits(foo) <- c(0, 0, rep(3, 9))
class(foo) <- "TableMonster"
print(foo, rowcolor=list(color="yellow", rownum=7))
|
Loading required package: xtable
TableMonster 1.7
Type ?print.TableMonster
% latex table generated in R 4.0.3 by xtable 1.8-4 package
% Wed Apr 28 20:14:46 2021
\begin{table}[ht]
\centering
\begin{tabular}{lrr}
\toprule
Name&Gender&Student ID\\
\cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(l){3-3}
John & male & 12345 \\
Joe & male & 54321 \\
Mary & female & 46943 \\
Jane & female & 23123 \\
Alex & female & 51234 \\
John & male & 12345 \\
Joe & male & 54321 \\
Mary & female & 46943 \\
Jane & female & 23123 \\
Alex & female & 51234 \\
\bottomrule
\end{tabular}
\caption{This is JUST a TEST}
\end{table}
% latex table generated in R 4.0.3 by xtable 1.8-4 package
% Wed Apr 28 20:14:46 2021
\begin{table}[ht]
\centering
\begin{tabular}{lrr}
\toprule
Name&Gender&Student ID\\
\cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(l){3-3}
John & male & 12345 \\
Joe & male & 54321 \\
Mary & female & 46943 \\
Jane & female & 23123 \\
Alex & female & 51234 \\
John & male & 12345 \\
Joe & male & 54321 \\
Mary & female & 46943 \\
Jane & female & 23123 \\
Alex & female & 51234 \\
\bottomrule
\end{tabular}
\caption{This is JUST a TEST}
\label{tbl:anexample}
\end{table}
% latex table generated in R 4.0.3 by xtable 1.8-4 package
% Wed Apr 28 20:14:46 2021
\begin{table}[ht]
\centering
\begin{tabular}{lrr}
\toprule
Name&Gender&Student ID\\
\cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(l){3-3}
John & male & 12345 \\
Joe & male & 54321 \\
Mary & female & 46943 \\
Jane & female & 23123 \\
Alex & female & 51234 \\
John & male & 12345 \\
Joe & male & 54321 \\
Mary & female & 46943 \\
Jane & female & 23123 \\
Alex & female & 51234 \\
\bottomrule
\end{tabular}
\caption{This is JUST a TEST}
\end{table}
% latex table generated in R 4.0.3 by xtable 1.8-4 package
% Wed Apr 28 20:14:46 2021
\begin{table}[ht]
\centering
\begin{tabular}{lrr}
\toprule
Name&Gender&Student ID\\
\cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(l){3-3}
John & male & 12345 \\
Joe & male & 54321 \\
Mary & female & 46943 \\
Jane & female & 23123 \\
Alex & female & 51234 \\
John & male & 12345 \\
Joe & male & 54321 \\
Mary & female & 46943 \\
Jane & female & 23123 \\
Alex & female & 51234 \\
\bottomrule
\end{tabular}
\caption{This is JUST a TEST}
\label{tbl:anexample}
\end{table}
%% Don't forget to \usepackage{xcolor} and include 'table' in your documentclass options,
%% e.g. \documentclass[table]{beamer}, and remember to define the color, yellow, in your preamble
% latex table generated in R 4.0.3 by xtable 1.8-4 package
% Wed Apr 28 20:14:46 2021
\begin{table}[ht]
\centering
\begin{tabular}{lrrrrrrrrrr}
\toprule
&&\multicolumn{3}{c}{Model 1}&\multicolumn{3}{c}{Model 2}&\multicolumn{3}{c}{Model 3}\\
\cmidrule(r){3-5}\cmidrule(lr){6-8}\cmidrule(l){9-11}
Variable&Group&Estimate&Std Err&Wald Test&Estimate&Std Err&Wald Test&Estimate&Std Err&Wald Test\\
\cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(lr){3-3}\cmidrule(lr){4-4}\cmidrule(lr){5-5}\cmidrule(lr){6-6}\cmidrule(lr){7-7}\cmidrule(lr){8-8}\cmidrule(lr){9-9}\cmidrule(lr){10-10}\cmidrule(l){11-11}
b & 1 & 0.180 & 0.087 & 2.082 & -0.567 & 0.078 & -7.286 & 0.017 & 0.141 & 0.117 \\
j & 1 & 1.118 & 0.080 & 13.913 & 1.198 & 0.021 & 57.126 & 0.146 & 0.170 & 0.860 \\
h & 1 & -0.326 & 0.403 & -0.808 & -0.539 & 0.389 & -1.387 & -1.728 & 0.309 & -5.597 \\
a & 1 & -0.972 & 0.246 & -3.960 & 0.963 & 0.410 & 2.351 & 0.606 & 0.241 & 2.518 \\
d & 1 & 0.765 & 0.174 & 4.401 & -0.055 & 0.608 & -0.091 & -0.618 & 0.313 & -1.973 \\
f & 2 & -0.834 & 0.587 & -1.420 & 1.997 & 0.088 & 22.720 & 0.282 & 0.746 & 0.379 \\
\rowcolor{yellow}c & 2 & -2.379 & 0.102 & -23.393 & -0.665 & 0.188 & -3.541 & -0.781 & 0.183 & -4.276 \\
i & 2 & -0.285 & 0.275 & -1.040 & 0.567 & 0.231 & 2.449 & -0.160 & 0.547 & -0.294 \\
g & 2 & 0.939 & 0.632 & 1.486 & -1.652 & 0.263 & -6.283 & 0.706 & 0.209 & 3.380 \\
e & 2 & 0.380 & 0.284 & 1.337 & 1.232 & 0.040 & 30.777 & -0.616 & 0.448 & -1.375 \\
\bottomrule
\end{tabular}
\caption{This is TableMonster (TM)!!!}
\end{table}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.