blob: 799dac177535d224dac51a42368c0c13090ae119 [file] [log] [blame]
Hao Zhue10cfd32017-02-21 16:41:14 -05001#' kableExtra
2#'
Hao Zhu76281fe2017-07-03 19:33:09 -04003#' @description When we are talking about table generators in R,
Hao Zhu7f3fa852020-08-26 13:55:38 -04004#' [knitr](https://yihui.org/knitr/)'s `kable()` function wins lots of flavor
Hao Zhu76281fe2017-07-03 19:33:09 -04005#' by its ultimate simplicity. Unlike those powerful table rendering engines
6#' such as [`xtable`](https://CRAN.R-project.org/package=xtable), the philosophy
7#' behind [`knitr::kable()`](https://rdrr.io/cran/knitr/man/kable.html) is to
8#' make it easy for programmers to use. Just as it claimed in its
9#' function description, "this is a very simple table generator. It is simple
10#' by design. It is not intended to replace any other R packages for making
11#' tables. - Yihui".
12#'
13#' However, the ultimate simplicity of `kable()` also brought troubles to some
14#' of us, especially for new R users, who may not have a lot of experience on
15#' generating tables in R. It is not rare to see people including experienced
16#' users asking questions like how to center/left-align a table on Stack
17#' Overflow. Also, for me personally, I found myself repeatedly parsing CSS
18#' into `kable()` for some very simple features like striped lines. For LaTeX,
19#' it's even worse since I'm almost Stack Overflow dependent for LaTeX...
20#' That's why this package `kableExtra` was created.
21#'
22#' I hope with `kableExtra`, you can
23#' - Use default base `kable()` (Or a good alternative for markdown tables is
24#' `pander::pander()`) for all simple tables
25#' - Use `kable()` with `kableExtra` to generate 90 % of complex/advanced
26#' tables in either HTML or LaTeX
27#' - Only have to mess with raw HTML/LaTeX in the last 10% cases where
28#' `kableExtra` cannot solve the problem
29#'
Hao Zhu4b0c51e2017-08-01 15:21:07 -040030#' For a full package documentation, please visit the
Hao Zhu7f3fa852020-08-26 13:55:38 -040031#' [package documentation site](https://haozhu233.github.io/kableExtra/)
Hao Zhu4b0c51e2017-08-01 15:21:07 -040032#' for more information
33#'
Hao Zhu76281fe2017-07-03 19:33:09 -040034#' @section Features:
35#' **Pipable syntax:** `kableExtra` is NOT a table generating package. It is a
36#' package that can "add features" to a `kable` output using a syntax
Hao Zhu7f3fa852020-08-26 13:55:38 -040037#' that every useR loves - the [pipe](https://r4ds.had.co.nz/pipes.html).
Hao Zhu76281fe2017-07-03 19:33:09 -040038#' We see similar approaches to deal with plots in packages like `ggvis` and
39#' `plotly`. There is no reason why we cannot use it with tables.
40#'
41#' **Unified functions for both HTML and PDF:** Most functionalities in
42#' `kableExtra` can work in both HTML and PDF. In fact, as long as you
43#' specifies format in `kable` (which can be set globally through option
44#' `knitr.table.format`), functions in this package will pick the right way
45#' to manipulate the table be themselves. As a result, if users want to left
46#' align the table, `kable_styling(kable(...), position = "left")` will work
47#' in both HTML and PDF.
48#'
49#' @note If you found a feature on the documentation site that is not available
50#' in the version of `kableExtra` you are using, try to install the pre-release
51#' version from github. You can do so by running
52#' `devtools::install_github("haozhu233/kableExtra")`.
53#'
54#' Also, note that This package can load required LaTeX package automatically in
55#' vanilla rmarkdown. For customized rmarkdown templates, it is recommended to
56#' load related LaTeX packages manually.
57#'
Duncan Murdoch911dca32019-01-05 16:39:32 -050058#' @importFrom stringr fixed str_count str_split str_match str_detect str_match_all
Hao Zhub2b41992017-10-03 12:50:03 -040059#' str_extract str_replace_all str_trim str_extract_all str_sub str_replace
Hao Zhu26234122017-02-22 15:34:33 -050060#' @importFrom xml2 read_xml xml_attr xml_has_attr xml_attr<- read_html
Hao Zhuf7994dd2017-02-27 16:58:42 -050061#' xml_child xml_children xml_name xml_add_sibling xml_add_child xml_text
Hao Zhu9410a272020-08-03 01:11:47 -040062#' xml_remove write_xml xml_text<- xml_length
Hao Zhu26234122017-02-22 15:34:33 -050063#' @importFrom rvest html_table
Hao Zhu68b5bbf2018-03-26 11:30:34 -040064#' @importFrom knitr knit_meta_add include_graphics knit_print asis_output kable
Hao Zhueaef4312018-01-10 17:05:23 -050065#' @importFrom rmarkdown latex_dependency html_dependency_bootstrap
Hao Zhu73cf3732018-05-11 17:50:05 -040066#' html_dependency_jquery pandoc_self_contained_html
Hao Zhuf7994dd2017-02-27 16:58:42 -050067#' @importFrom magrittr %>%
Hao Zhu76f0eb62018-09-15 12:38:33 -040068#' @importFrom utils read.csv head capture.output
Hao Zhu9ce317e2017-10-12 18:19:55 -040069#' @importFrom scales rescale
70#' @importFrom viridisLite viridis
Hao Zhu5fe235c2020-08-26 00:26:49 -040071#' @importFrom stats ave density median
72#' @importFrom grDevices col2rgb svg png
Hao Zhu5b71b2d2018-03-26 16:31:09 -040073#' @importFrom rstudioapi isAvailable viewer
Hao Zhub548aac2018-09-18 13:29:01 -040074#' @importFrom glue glue
Hao Zhu7f8b6842018-10-23 17:41:13 -040075#' @importFrom tools file_ext file_path_sans_ext
76#' @importFrom webshot webshot
Duncan Murdoch911dca32019-01-05 16:39:32 -050077#' @importFrom digest digest
Hao Zhu5fe235c2020-08-26 00:26:49 -040078#' @importFrom graphics par text hist boxplot
Hao Zhueaef4312018-01-10 17:05:23 -050079#' @import htmltools
Hao Zhue10cfd32017-02-21 16:41:14 -050080#' @name kableExtra-package
81#' @aliases kableExtra
82#' @docType package
83#' @keywords package
84NULL
Hao Zhu26234122017-02-22 15:34:33 -050085
86#' @export
87magrittr::`%>%`
Hao Zhuf2be4822020-08-18 07:44:10 -040088
89#' @export
90knitr::kable