TexRow {textab} | R Documentation |
This function creates a row of a LaTeX table.
Description
This function creates a row of a LaTeX table.
Usage
TexRow(
value,
cspan = rep(1, length(value)),
position = "c",
surround = "%s",
space = 0,
dec = 3,
percentage = FALSE,
dollar = FALSE,
se = FALSE,
pvalues = NULL
)
Arguments
value |
The value(s) to be formatted. Must be a numeric or character vector. |
cspan |
(integer). If greater than 1, |
position |
(character). If cspan > 1, |
surround |
(character). This will be applied to the value as sprintf(surround, value), so surround must contain the "%s" placeholder. Default is "%s". |
space |
(numeric). The number of points (pt) of vertical space to append to the end of the row. Default is 0. |
dec |
(integer). Only relevant if |
percentage |
(logical). Only relevant if |
dollar |
(logical). Only relevant if |
se |
(logical). Only relevant if |
pvalues |
(numeric). Only relevant if |
Value
The output is a textab block.
Examples
# basic character row:
vec = c("hello", "world")
TexRow(vec)
# character row with LaTeX formatting:
vec = c('Hello','\\textbf{World}','$\\alpha$','$\\frac{1}{2}$')
TexRow(vec)
# basic numeric row:
vec <- c(1.0, 1.01, 1.001)
TexRow(vec)
TexRow(vec, dec = 2) # round to second decimal place
# custom formatting of numbers using surround argument:
vec = c(5.081, 2.345, 6.789)
TexRow(vec, dec = 1, surround = "{\\color{red} %s}")
# use cspan argument to merge the second and third rows:
vec = c("hello", "world")
TexRow(vec, cspan = c(1,2))
TexRow(vec, cspan = c(1,2), position = "c") # center merged columns
# concatenate blocks vertically or horizontally:
block1 = TexRow(c("hello","world","block"))
block2 = TexRow(c(5.081, 2.345, 6.789), dec=1)
block1 / block2 # horizontal
block1 + block2 # vertical
# add 3pt of vertical space between two rows using the space argument:
TexRow(c("hello", "world"), space=3) + TexRow(c('$\\alpha$','$\\frac{1}{2}$'))