kablerow: kablerow a replacement for knitr::kable which enables row...

View source: R/rutils.R

kablerowR Documentation

kablerow a replacement for knitr::kable which enables row formatting

Description

knitr::kable enables one to round the number of digits for each column of a table. However, sometimes one wants to format the rows and not the columns. kablerow enables that while using the kable function. It rounds the rows to the desired number of digits and then converts those rounded values to characters, which kable can then print more appropriately.

Usage

kablerow(x, rowdigits, namerows = NA, namecols = NA)

Arguments

x

an input matrix or data.frame

rowdigits

the number of digits desired for each row

namerows

should row.names be printed; default=NA. change to TRUE for row.names printing

namecols

should col.names be printed; default=NA (which prints V1, V2 ,V3, ...)

Value

Nothing but it does use knitr::kable to print a formatted matrix

Examples

x <- matrix(rnorm(25,mean=5,sd=1),nrow=5,ncol=5)
colnames(x) <- 1:5
numdig <- c(2,3,4,3,2)
rownames(x) <- c("a","b","c","d","e")
kablerow(x,rowdigits=c(2,3,4,3,2),namerows=TRUE)

haddonm/codeutils documentation built on April 15, 2024, 1:02 p.m.