Learn R Programming

qwraps2 (version 0.2.2)

qable: Qable: an extended verion of knitr::kable

Description

Create a simple table via kable with row groups and rownames similar to those of hmisc::latex or htmlTable::htmlTable.

Usage

qable(x, rgroup, rnames = rownames(x), cnames = colnames(x), markup = getOption("qwraps2_markup", "latex"), ...)

Arguments

x
matrix or data.frame to be turned into a qable
rgroup
a named numeric vector with the name of the row group and the number of rows within the group. sum(rowgroup) == nrow(x).
rnames
a character vector of the row names
cnames
column names
markup
the markup language to use, passed to the format argument of knitr::kable.
...
additional arguments passed to knitr::kable

Value

a character vector of the formatted numbers

Details

qable is used as the printing method for qwraps2_summary_table objects. Check the vignettes for examples on building data summary tables.

See Also

kable summary_table, for

Examples

Run this code
data(mtcars)
qable(mtcars)
qable(mtcars, markup = "markdown")

# by make
make <- sub("^(\\w+)\\s?(.*)$", "\\1", rownames(mtcars))
make <- c(table(make))

qable(mtcars[sort(rownames(mtcars)), ], rgroup = make)
qable(mtcars[sort(rownames(mtcars)), ], rgroup = make, markup = "markdown")

# define your own column names
qable(mtcars[sort(rownames(mtcars)), ], 
      rgroup = make, 
      cnames = toupper(colnames(mtcars)), 
      markup = "markdown")

Run the code above in your browser using DataLab