Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 1 | #' kableExtra |
| 2 | #' |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 3 | #' @description When we are talking about table generators in R, |
| 4 | #' [knitr](https://yihui.name/knitr/)'s `kable()` function wins lots of flavor |
| 5 | #' 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 | #' |
| 30 | #' @section Features: |
| 31 | #' **Pipable syntax:** `kableExtra` is NOT a table generating package. It is a |
| 32 | #' package that can "add features" to a `kable` output using a syntax |
| 33 | #' that every useR loves - the [pipe](http://r4ds.had.co.nz/pipes.html). |
| 34 | #' We see similar approaches to deal with plots in packages like `ggvis` and |
| 35 | #' `plotly`. There is no reason why we cannot use it with tables. |
| 36 | #' |
| 37 | #' **Unified functions for both HTML and PDF:** Most functionalities in |
| 38 | #' `kableExtra` can work in both HTML and PDF. In fact, as long as you |
| 39 | #' specifies format in `kable` (which can be set globally through option |
| 40 | #' `knitr.table.format`), functions in this package will pick the right way |
| 41 | #' to manipulate the table be themselves. As a result, if users want to left |
| 42 | #' align the table, `kable_styling(kable(...), position = "left")` will work |
| 43 | #' in both HTML and PDF. |
| 44 | #' |
| 45 | #' @note If you found a feature on the documentation site that is not available |
| 46 | #' in the version of `kableExtra` you are using, try to install the pre-release |
| 47 | #' version from github. You can do so by running |
| 48 | #' `devtools::install_github("haozhu233/kableExtra")`. |
| 49 | #' |
| 50 | #' Also, note that This package can load required LaTeX package automatically in |
| 51 | #' vanilla rmarkdown. For customized rmarkdown templates, it is recommended to |
| 52 | #' load related LaTeX packages manually. |
| 53 | #' |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 54 | #' @importFrom stringr str_count str_split str_match str_detect str_match_all |
Hao Zhu | fdec184 | 2017-06-08 17:06:04 -0400 | [diff] [blame] | 55 | #' str_extract str_replace_all str_trim str_extract_all str_sub |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 56 | #' @importFrom xml2 read_xml xml_attr xml_has_attr xml_attr<- read_html |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 57 | #' xml_child xml_children xml_name xml_add_sibling xml_add_child xml_text |
Hao Zhu | 2a87e8e | 2017-06-14 15:49:33 -0400 | [diff] [blame] | 58 | #' xml_remove xml_text<- |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 59 | #' @importFrom rvest html_table |
Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 60 | #' @importFrom knitr knit_meta_add |
| 61 | #' @importFrom rmarkdown latex_dependency |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 62 | #' @importFrom magrittr %>% |
| 63 | #' @importFrom utils read.csv |
Hao Zhu | a31e97f | 2017-06-08 14:55:41 -0400 | [diff] [blame] | 64 | #' @importFrom readr read_lines |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 65 | #' @name kableExtra-package |
| 66 | #' @aliases kableExtra |
| 67 | #' @docType package |
| 68 | #' @keywords package |
| 69 | NULL |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 70 | |
| 71 | #' @export |
| 72 | magrittr::`%>%` |