Version: | 1.7.8 |
Depends: | xtable |
Title: | Table Monster |
Description: | Provides a user friendly interface to generation of booktab style tables using 'xtable'. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
NeedsCompilation: | no |
Packaged: | 2025-05-21 14:46:14 UTC; kthj862 |
Repository: | CRAN |
Date/Publication: | 2025-05-22 05:00:13 UTC |
Author: | Grant Izmirlian [aut, cre] |
Maintainer: | Grant Izmirlian <grant.izmirlian@astrazeneca.com> |
Simple Call to print.TableMonster
Description
For a generic table ready data.frame, 'x', the call basic.tmPrint(x) produces booktabs style latex table suitable for publication
Usage
basic.tmPrint(x, special = NULL, simple = FALSE, dbg = FALSE, ...)
Arguments
x |
A table ready data.frame |
special |
Special arguments to print.TableMonster. See object documentation. |
simple |
The remnants of a call to the print method, e.g. if x is a table ready data.frame then print(x, simple=TRUE) calls this function. |
dbg |
set to a value >= 1 for debugging |
... |
other arguments to print.TableMonster |
Value
An invisible version of the argument 'x'
Author(s)
Grant Izmirlian
The paste operator
Description
A binary operator shortcut for paste(x,y)
Usage
x %,% y
Arguments
x |
a character string |
y |
a character string |
Value
The concatenated character string
Author(s)
Grant Izmirlian grant.izmirlian@astrazeneca.com
Examples
"var" %,% (1:10)
Easy Generation of 'booktab' tables
Description
Provides a user friendly interface to generation of booktab style tables using xtable.
Usage
## S3 method for class 'TableMonster'
print(x, extra = NULL, special = NULL, simple = FALSE, dbg = FALSE, ...)
Arguments
x |
an object of class 'TableMonster' – see below |
extra |
If you want a solid line (tr) or centered midlines (cr) anywhere in the body of the table then use this list argument, with a 'tl' for each solid and a 'mr' for each centered midline in the same format ast the top, e.g. extra=list(tr=11, cr=13) will put one of each after body lines 11 and 13. |
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, |
Author(s)
Grant Izmirlian izmirlian@astrazeneca.com
Examples
## 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))
Gets the attribute 'caption' from a 'TableMonster' class object
Description
Gets the attribute 'caption' from a 'TableMonster' class object
Usage
tmCaption(x)
Arguments
x |
An object of class 'TableMonster' |
Details
This is a required attribute for an object of class 'TableMonster'
Value
A character string
Author(s)
Grant Izmirlian
Assignment function for the 'caption' attribute
Description
Assignment function for the 'caption' attribute of an object of class 'TableMonster'
Usage
tmCaption(x) <- value
Arguments
x |
An object of class 'TableMonster' |
value |
A character string |
Details
This is a required attribute for an object of class 'TableMonster'
Author(s)
Grant Izmirlian
Gets the attribute 'ctypes' from a 'TableMonster' class object
Description
Gets the attribute 'ctypes' from a 'TableMonster' class object
Usage
tmCtypes(x)
Arguments
x |
An object of class 'TableMonster' |
Details
This is a required attribute for an object of class 'TableMonster'
Value
A character vector the same length as the number of columns of the table, having entries "n" or "c", meaning "numeric" or "character"
Author(s)
Grant Izmirlian
Assignment function for the 'ctypes' attribute
Description
Assignment function for the 'ctypes' attribute of an object of class 'TableMonster'
Usage
tmCtypes(x) <-value
Arguments
x |
An object of class 'TableMonster' |
value |
A vector of length equal to the number of columns in the table containing entries "n" or "c" meaning that the corresponding column is of mode "numeric" or "character" |
Details
This is a required attribute for an object of class 'TableMonster'
Author(s)
Grant Izmirlian
Gets the attribute 'digits' from a 'TableMonster' class object
Description
Gets the attribute 'digits' from a 'TableMonster' class object
Usage
tmDigits(x)
Arguments
x |
An object of class 'TableMonster' |
Details
This is a required attribute for an object of class 'TableMonster'
Value
A numeric vector of length equal to the number of columns in the table
Author(s)
Grant Izmirlian
Assignment function for the 'digits' attribute
Description
Assignment function for the 'digits' attribute of an object of class 'TableMonster'
Usage
tmDigits(x) <- value
Arguments
x |
An object of class 'TableMonster' |
value |
A numeric vector of length equal to the number of columns in the table specifying the desired number of digits. Enter '0' for character columns. |
Details
This is a required attribute for an object of class 'TableMonster'
Author(s)
Grant Izmirlian
Gets the 'display' attribute
Description
Gets the 'display' attribute of an object of class 'TableMonster'
Usage
tmDisplay(x)
Arguments
x |
An object of class 'TableMonster' |
Details
This attribute is optional and is only used when you want to specify the format type for each column as other than "g" (general format).
Value
A vector of length exceeding the number of columns by 1 consiting of the format specifiers, '"d"' (for integers), '"f"', '"e"', '"E"', '"g"', '"G"', '"fg"' (for reals), or '"s"' (for strings).
Author(s)
Grant Izmirlian
Assignment function for the 'display' attribute
Description
Assignment function for the 'display' attribute of an object of class 'TableMonster'
Usage
tmDisplay(x) <- value
Arguments
x |
An object of class 'TableMonster' |
value |
A vector of length exceeding the number of columns by 1 consiting of the format specifiers, '"d"' (for integers), '"f"', '"e"', '"E"', '"g"', '"G"', '"fg"' (for reals), or '"s"' (for strings). |
Details
This attribute is optional and is only used when you want to specify the format type for each column as other than "g" (general format).
Author(s)
Grant Izmirlian
Gets the attribute 'headings' from a 'TableMonster' class object
Description
Gets the attribute 'headings' from a 'TableMonster' class object
Usage
tmHeadings(x)
Arguments
x |
An object of class 'TableMonster' |
Details
This is a required attribute for an object of class 'TableMonster'
Value
The 'headings' attribute of a 'TableMonster' object, a vector of character strings of length equal to the number of columns of the table.
Author(s)
Grant Izmirlian
Assignment function for the 'headings' attribute
Description
Assignment function for the 'headings' attribute for an object of class 'TableMonster'
Usage
tmHeadings(x) <- value
Arguments
x |
An object of class 'TableMonster' |
value |
A vector of character strings of length equal to the number of columns in the table |
Details
This is a required attribute for an object of class 'TableMonster'
Author(s)
Grant Izmirlian
Gets the 'totals' attribute
Description
Gets the 'totals' attribute of an object of class 'TableMonster'
Usage
tmTotals(x)
Arguments
x |
An object of class 'TableMonster' |
Details
This attribute is optional and is only used when you have a table in which you want to put a single row of column totals (or anything else) below the bottom line.
Value
A numeric or character vector of length equal to the number of columns in the table
Author(s)
Grant Izmirlian
Assignment function for the 'totals' attribute
Description
Assignment function for the 'totals' attribute of an object of class 'TableMonster'
Usage
tmTotals(x) <- value
Arguments
x |
An object of class 'TableMonster' |
value |
The 'totals' attribute, a numeric or character vector of length equal to the number of columns in the table. |
Details
This attribute is optional and is only used when you have a table in which you want to put a single row of column totals (or anything else) below the bottom line.
Author(s)
Grant Izmirlian