writeTabular: Write a table in LaTeX format

Description Usage Arguments Value See Also Examples

Description

This is a simple function to create tabular environment in LaTeX

Usage

1
2
3
4
5
6
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

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

Example output

\begin{tabular}{ll|llllllll}
\hline
Size & Radius & FruitFly & Shukla & Ikeda & Turau & Rand1 & Rand2 & FrogCOL & FrogMIS \\
\hline
1000 & 0.049 & 226.27 & 212.40 & 213.20 & 211.90 & 212.70 & 214.53 & {\bf 247.67} & 227.60 \\
1000 & 0.058 & 174.90 & 162.87 & 162.00 & 162.70 & 161.47 & 163.47 & {\bf 189.90} & 176.93 \\
1000 & 0.067 & 142.23 & 130.83 & 130.37 & 129.87 & 129.83 & 129.60 & {\bf 151.93} & 140.57 \\
1000 & 0.076 & 117.80 & 105.30 & 104.60 & 105.30 & 105.30 & 104.90 & {\bf 122.87} & 114.13 \\
1000 & 0.085 & 99.43 & 87.43 & 85.87 & 86.70 & 86.73 & 87.07 & {\bf 102.37} & 94.33 \\
1000 & 0.094 & {\bf 85.80} & 74.20 & 72.87 & 72.90 & 72.63 & 72.30 & 85.47 & 79.33 \\
1000 & 0.103 & {\bf 75.57} & 63.17 & 62.77 & 62.13 & 63.23 & 62.30 & 74.20 & 68.13 \\
1000 & 0.112 & {\bf 66.90} & 54.50 & 54.07 & 54.83 & 54.17 & 54.37 & 64.37 & 58.20 \\
1000 & 0.121 & {\bf 59.53} & 47.97 & 47.43 & 47.17 & 47.03 & 47.60 & 56.50 & 51.30 \\
1000 & 0.134 & 24.27 & 40.77 & 40.07 & 40.10 & 39.93 & 40.10 & {\bf 47.53} & 43.10 \\
\hline
100 & 0.140 & 27.80 & 25.63 & 25.70 & 25.90 & 26.17 & 26.10 & {\bf 31.07} & 29.10 \\
100 & 0.143 & 26.80 & 25.43 & 25.60 & 25.53 & 25.17 & 25.73 & {\bf 30.53} & 28.57 \\
100 & 0.146 & 26.57 & 24.90 & 25.37 & 25.80 & 25.07 & 25.30 & {\bf 29.93} & 28.03 \\
100 & 0.149 & 25.80 & 24.47 & 23.97 & 24.40 & 23.87 & 24.40 & {\bf 29.10} & 27.33 \\
100 & 0.152 & 25.03 & 23.77 & 23.57 & 23.57 & 23.83 & 23.87 & {\bf 28.47} & 25.97 \\
100 & 0.155 & 24.13 & 23.27 & 22.87 & 23.00 & 22.63 & 22.90 & {\bf 27.30} & 25.47 \\
100 & 0.158 & 24.03 & 22.47 & 22.63 & 22.50 & 22.40 & 22.90 & {\bf 27.33} & 24.57 \\
100 & 0.161 & 22.80 & 21.70 & 21.03 & 21.93 & 21.57 & 21.40 & {\bf 25.83} & 23.40 \\
100 & 0.164 & 22.40 & 20.80 & 20.67 & 20.90 & 20.93 & 21.43 & {\bf 25.57} & 22.93 \\
100 & 0.169 & 21.73 & 20.57 & 20.10 & 20.03 & 20.13 & 20.17 & {\bf 24.50} & 22.20 \\
\hline
5000 & 0.024 & 964.53 & 898.23 & 899.60 & 902.50 & 897.83 & 905.30 & {\bf 975.90} & 972.40 \\
5000 & 0.036 & {\bf 515.83} & 459.30 & 453.87 & 452.97 & 455.57 & 456.60 & 502.00 & 495.30 \\
5000 & 0.048 & {\bf 332.13} & 276.40 & 273.67 & 273.00 & 275.23 & 273.83 & 309.17 & 294.10 \\
5000 & 0.060 & 42.03 & 185.60 & 182.30 & 183.43 & 184.73 & 183.00 & {\bf 210.90} & 196.93 \\
5000 & 0.072 & 2.80 & 134.97 & 131.20 & 131.47 & 132.50 & 131.90 & {\bf 153.90} & 139.87 \\
5000 & 0.084 & 0.27 & 102.03 & 99.87 & 99.60 & 99.37 & 99.83 & {\bf 117.90} & 105.73 \\
5000 & 0.096 & 0.00 & 79.97 & 78.77 & 78.60 & 78.73 & 78.20 & {\bf 93.30} & 82.57 \\
5000 & 0.108 & 0.00 & 64.50 & 63.73 & 63.40 & 63.33 & 63.10 & {\bf 75.83} & 67.43 \\
5000 & 0.120 & 0.00 & 54.07 & 52.10 & 51.90 & 52.63 & 52.60 & {\bf 63.27} & 54.57 \\
5000 & 0.134 & 0.00 & 44.27 & 43.43 & 43.47 & 43.10 & 43.07 & {\bf 52.20} & 45.47 \\
\hline
\end{tabular}

scmamp documentation built on May 1, 2019, 10:10 p.m.