print.TableMonster: Easy Generation of 'booktab' tables

Description Usage Arguments Author(s) References Examples

Description

Provides a user friendly interface to generation of booktab style tables using xtable.

Usage

1
2
## S3 method for class 'TableMonster'
print(x, special = NULL, simple = FALSE, dbg = FALSE, ...)

Arguments

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, label, of type character, giving the name of the latex label name associated with the table for crossreference within the latex document. 2. Optionally special, a charcter string taking the value "jrss-b" or "aos". 3. Optionally rowcolor, a list of the form list(color="yellow", rownum=5), for highlighting a particular row. You must remember to \usepackage{xcolor} and include 'table' in your documentclass options, e.g. \documentclass[table]{beamer}, and of course, define the color 'yellow' in your preamble. Finally, any named arguments accepted by print.xtable are accepted.

Author(s)

Grant Izmirlian

References

<https://www.youtube.com/watch?v=CM1TaNVnh58>

Examples

 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))

TableMonster documentation built on May 1, 2019, 8:44 p.m.