Skip to contents

Create an output-independent, well formatted kable table

Usage

create_knitr_table(
  data_table,
  digits = NULL,
  caption = NA,
  col.names = NULL,
  col_width = NULL,
  width_unit = "cm",
  col_align = NULL,
  border_right_cols = NULL,
  bold_cols = NULL,
  bootstrap_options = c("striped", "hover", "condensed"),
  latex_options = NULL,
  output_format = NULL,
  keep_pdf = FALSE,
  latex_header_includes = c("\\usepackage[magyar]{babel}",
    "\\usepackage[utf8]{inputenc}")
)

Arguments

data_table

data.frame, tibble, named matrix or a knitr_kable object.

digits

Number of digits to display in the case of numeric variables.

caption

A table caption, defaults to empty NA.

col.names

The col.names parameter of the kable table, if NULL, filled with the names of the data_table.

col_width

Defaults to NULL. In this case all col_align parameters will be "c" for centered.

width_unit

Defaults to "cm".

col_align

Defaults to NULL. In this case 'l' for the first column and 'r' for the rest of the columns, i.e."l", "c", ..., "c"

border_right_cols,

Defaults to NULL. In this case TRUE for the first column and FALSE for the rest of the columns, i.e.T, F, ..., F

bold_cols

Defaults to NULL. In this case none of the the columns are bold, i.e. identical to F, F, ..., F.

bootstrap_options

Defaults to c("striped", "hover", "condensed") and only used for output_format = "html".

latex_options

Defaults to NULL).

output_format

Defaults to 'html'. Alternatives are 'latex'. 'image', recommended for Word files, is removed because it depends on magick which is not available on all R platforms.

keep_pdf

Defaults to FALSE and only used if output_format = 'image'.

latex_header_includes

Currently defaults to c( "\usepackage[magyar]{babel}", "\usepackage[utf8]{inputenc}") It can be any valid latex option setting, but if packages are used, the packages must be installed on your Latex engine.

Examples

foo = data.frame ( 
  observation = c("indicator1", "indicator2", "indicator3"), 
  indicator_1 = c(100,105,95), 
  indicator_2 = c(102,104,76)
  )