pretty_table: Wrapper function for pretty tables

Description Usage Arguments Value Examples

Description

Wraps table functions to provide a single user interface. A footer can be added but this requies rows to be merged once the document has been knit to word.

Usage

1
2
pretty_table(df, col_names = NULL, footer = NULL, cap_fun = pretty_tabref,
  label = NULL, caption = NULL, tab_fun = pander, ...)

Arguments

df

A data frame to be converted to a markdown table. Optionally a vector can be passed, this will be reformatted into a data frame with the vectors names used in the firt column.

col_names

A character vector of replacement column names.

footer

The desired footer as a character string.

cap_fun

Caption function to wrap, if supplied pretty_table defaults to defining an empty caption.

label

A character string of the reference label for the table

caption

A character string of the required table caption.

tab_fun

Table function to wrap. Supported functions are pander and kable, with pander set as the default.

...

Pass additional arguements to the wrapped table function.

Value

A markdown table

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## A simple table
pretty_table(iris[1:5, 1:5])

## Renaming columns
pretty_table(iris[1:5, 1:5], col_names = as.character(1:5))

## Adding a footer
pretty_table(iris[1:5, 1:5], footer = 'Example footer')

## Changing to a kable table
library(knitr)

pretty_table(iris[1:5, 1:5], tab_fun = kable)

## Passing a named vector of values
pretty_table(c(b = 1, c = 2, a = 3))

seabbs/prettypublisher documentation built on May 30, 2019, 10:36 p.m.