Learn R Programming

scmamp (version 0.2.55)

writeTabular: Write a table in LaTeX format

Description

This is a simple function to create tabular environment in LaTeX

Usage

writeTabular(table, file = NULL, format = "g", bold = NULL, italic = NULL, mark = NULL, mark.char = "*", na.as = "n/a", align = "l", hrule = NULL, vrule = NULL, bty = c("t", "b", "l", "r"), print.col.names = TRUE, print.row.names = TRUE, digits = 3, wrap.as.table = FALSE, table.position = "h", caption = NULL, caption.position = "b", centering = FALSE, label = NULL)

Arguments

table
A data frame with the information to write
file
Path of a file. If provided, the tabular is wirten in the given file. Otherwise, it is writen to the standard output
format
Format for the numeric values. The accepted formats are those in the function formatC. The typical values are 'g' to automatically set the format, 'f' for a fixed sized floating point format and 'e' or 'E' for scientific notation
bold
A matrix that matches 'table' in size indicating with TRUE those cells that have to be printed in bold font
italic
A matrix that matches 'table' in size indicating with TRUE those cells that have to be printed in italic
mark
A matrix that matches 'table' in size indicating with TRUE those cells that have to be marked with a superscipt symbol
mark.char
Character to be used to mark cells. Note that the superscript is included in a math environment, so this has to be either a character or a valid math command in LaTeX
na.as
Character to be used to write NA values in the table
align
Character indicating the alignment of the colums ('l','r' or 'c')
hrule
A vector of positions for the horizontal lines in the tabular. All the lines are drawn after the indicated line. When the column names are included, 0 means drawing a line after the column names. The maximum value is the number of rows - 1 (for a line after the last line see parametr bty)
vrule
Similar to 'hrule' but for vertical lines. . The maximum value is the number of columns - 1 (for a line after the last columns see parametr bty)
bty
Vector indicating which borders should be printed. The vector can contain any of subset of c('l','r','t','b'), which represent, respectively, left, right, top and bottom border. If the parameter is set to NULL no border is printed.
print.col.names
Logical value indicating whether the column names have to be printed or not
print.row.names
Logical value indicating whether the row names have to be printed or not
digits
A single number or a numeric vector with the number of digits in each column. Its size has to match the number of the final table, i.e., the colums in 'table' if the row names are not included or the number of columns + 1 if the row names are printed in the final table
wrap.as.table
Logical value indicating whether the latex object has to be wrapped into a table enviroment
table.position
Character indicating the position of the table ('h': here, 't': top, or 'b': botton)
caption
Character string containing the caption of the table. If NULL, no caption is printed
caption.position
Character indicating the possition of the caption (t: top, the caption is printed over the table; b: botton, the caption is printed under the table)
centering
Logical value indicating whether the table should be centered in the page
label
Character string containing the label of the table for further references. If NULL, no label is used

Value

LaTeX code to print the table

See Also

summarizeData, filterData and the vignette vignette(topic="Data_loading_and_manipulation", package="scmamp")

Examples

Run this code
data(data_blum_2015)
args <- list()
# Write the summarization of the data
args$table <- summarizeData(data.blum.2015, group.by=1:2)

# Set in bold the maximum values per row
bold <- apply(args$table[, -(1:2)], MARGIN=1, 
             FUN=function(x) {
               return(x==max(x))
             })
args$bold <- cbind(FALSE, FALSE, t(bold))
# Fixed width, 2 decimals for the values, 0 for the size and 3 for the radius
args$format <- "f"
args$digits <- c(0,3,rep(2, 8))

# Print the colum names but not the row names
args$print.row.names <- FALSE

# Only top and bottom borders
args$bty <- c("t","b")

# Add additional horizontal rules to separate the sizes
args$hrule <- c(0,10,20,30)

# An additional vertical rule to separate size and radius from the results
args$vrule <- 2

# Print the table
do.call(writeTabular, args)

Run the code above in your browser using DataLab