bk: Beautify the output of knitr::kable

View source: R/bk.R

bkR Documentation

Beautify the output of knitr::kable

Description

Trailing zeros after integer is somewhat annoying. This removes those in the vector of strings.

Usage

  bk(ktab, rpltag=c("n", "N"), dig=10)

Arguments

ktab

an output of knitr::kable

rpltag

tag string of replacement rows. This is usually "n" which means the sample count.

dig

maximum digits of decimals in the kable output

Details

This is convenient if used with tsum0, tsum1, tsum2, tsum3, This requires knitr::kable.

Value

A new processed vector of strings. The class is still knitr_kable.

Author(s)

Kyun-Seop Bae k@acr.kr

See Also

tsum0, tsum1, tsum2, tsum3

Examples

## OUTPUT example
# t0 = tsum0(CO2, "uptake", c("mean", "median", "sd", "length", "min", "max"))
# bk(kable(t0)) # requires knitr package
#
# |       |        x|
# |:------|--------:|
# |mean   | 27.21310|
# |median | 28.30000|
# |sd     | 10.81441|
# |n      | 84      |
# |min    |  7.70000|
# |max    | 45.50000|

# t1 = tsum(uptake ~ Treatment, CO2, 
#           e=c("mean", "median", "sd", "min", "max", "length"), 
#           ou=c("chilled", "nonchilled"),
#           repl=list(c("median", "length"), c("med", "N")))
# 
# bk(kable(t1, digits=3)) # requires knitr package
# 
# |     | chilled| nonchilled| Combined|
# |:----|-------:|----------:|--------:|
# |mean |  23.783|     30.643|   27.213|
# |med  |  19.700|     31.300|   28.300|
# |sd   |  10.884|      9.705|   10.814|
# |min  |   7.700|     10.600|    7.700|
# |max  |  42.400|     45.500|   45.500|
# |N    |  42    |     42    |   84    |

sasLM documentation built on Nov. 19, 2023, 5:12 p.m.