| Title: | Table Monster |
|---|---|
| Description: | Provides a user friendly interface to generation of booktab style tables using 'xtable'. |
| Authors: | Grant Izmirlian [aut, cre] |
| Maintainer: | Grant Izmirlian <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.7.8 |
| Built: | 2026-05-18 07:49:59 UTC |
| Source: | https://github.com/cran/TableMonster |
For a generic table ready data.frame, 'x', the call basic.tmPrint(x) produces booktabs style latex table suitable for publication
basic.tmPrint(x, special = NULL, simple = FALSE, dbg = FALSE, ...)basic.tmPrint(x, special = NULL, simple = FALSE, dbg = FALSE, ...)
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 |
An invisible version of the argument 'x'
Grant Izmirlian
A binary operator shortcut for paste(x,y)
x %,% yx %,% y
x |
a character string |
y |
a character string |
The concatenated character string
Grant Izmirlian [email protected]
"var" %,% (1:10)"var" %,% (1:10)
Provides a user friendly interface to generation of booktab style tables using xtable.
## S3 method for class 'TableMonster' print(x, extra = NULL, special = NULL, simple = FALSE, dbg = FALSE, ...)## S3 method for class 'TableMonster' print(x, extra = NULL, special = NULL, simple = FALSE, dbg = FALSE, ...)
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, |
Grant Izmirlian [email protected]
## 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))## 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
tmCaption(x)tmCaption(x)
x |
An object of class 'TableMonster' |
This is a required attribute for an object of class 'TableMonster'
A character string
Grant Izmirlian
Assignment function for the 'caption' attribute of an object of class 'TableMonster'
tmCaption(x) <- valuetmCaption(x) <- value
x |
An object of class 'TableMonster' |
value |
A character string |
This is a required attribute for an object of class 'TableMonster'
Grant Izmirlian
Gets the attribute 'ctypes' from a 'TableMonster' class object
tmCtypes(x)tmCtypes(x)
x |
An object of class 'TableMonster' |
This is a required attribute for an object of class 'TableMonster'
A character vector the same length as the number of columns of the table, having entries "n" or "c", meaning "numeric" or "character"
Grant Izmirlian
Assignment function for the 'ctypes' attribute of an object of class 'TableMonster'
tmCtypes(x) <-valuetmCtypes(x) <-value
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" |
This is a required attribute for an object of class 'TableMonster'
Grant Izmirlian
Gets the attribute 'digits' from a 'TableMonster' class object
tmDigits(x)tmDigits(x)
x |
An object of class 'TableMonster' |
This is a required attribute for an object of class 'TableMonster'
A numeric vector of length equal to the number of columns in the table
Grant Izmirlian
Assignment function for the 'digits' attribute of an object of class 'TableMonster'
tmDigits(x) <- valuetmDigits(x) <- value
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. |
This is a required attribute for an object of class 'TableMonster'
Grant Izmirlian
Gets the 'display' attribute of an object of class 'TableMonster'
tmDisplay(x)tmDisplay(x)
x |
An object of class 'TableMonster' |
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).
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).
Grant Izmirlian
Assignment function for the 'display' attribute of an object of class 'TableMonster'
tmDisplay(x) <- valuetmDisplay(x) <- value
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). |
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).
Grant Izmirlian
Gets the attribute 'headings' from a 'TableMonster' class object
tmHeadings(x)tmHeadings(x)
x |
An object of class 'TableMonster' |
This is a required attribute for an object of class 'TableMonster'
The 'headings' attribute of a 'TableMonster' object, a vector of character strings of length equal to the number of columns of the table.
Grant Izmirlian
Assignment function for the 'headings' attribute for an object of class 'TableMonster'
tmHeadings(x) <- valuetmHeadings(x) <- value
x |
An object of class 'TableMonster' |
value |
A vector of character strings of length equal to the number of columns in the table |
This is a required attribute for an object of class 'TableMonster'
Grant Izmirlian
Gets the 'totals' attribute of an object of class 'TableMonster'
tmTotals(x)tmTotals(x)
x |
An object of class 'TableMonster' |
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.
A numeric or character vector of length equal to the number of columns in the table
Grant Izmirlian
Assignment function for the 'totals' attribute of an object of class 'TableMonster'
tmTotals(x) <- valuetmTotals(x) <- value
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. |
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.
Grant Izmirlian