blob: 792b5b3fed3998de32f9990d0ca021510d60d926 [file] [log] [blame]
Hao Zhue4145112015-11-05 17:52:59 -05001---
2output:
3 md_document:
4 variant: markdown_github
5---
6<!-- README.md is generated from README.Rmd. Please edit that file -->
7
Hao Zhudb04e302015-11-15 16:57:38 -05008This package is still in an "as-is" state. You can save a lot of finger-typing time by using it but you still need to understand what is really going on behind the hood, which is still far behind my goal. Also, since the default output format of `kable` is `markdown`, which doesn't support high-level table customization, it may not work well in many cases. I would recommend you to set the `format` option in each `kable` function or to define `options(knitr.table.format = 'html')` or `latex` somewhere in your document.
Hao Zhub1bc0aa2015-11-12 11:23:42 -05009
Hao Zhu4adea852015-11-16 16:38:34 -050010#Introduction to kableExtra
11When we are talking about table generators in `R`, `knitr::kable` wins the favor of a lot of people by its ultimate simplicity. Unlike those powerful table rendering engine such as `xtable`, `tables` or even `gridExtra`, the philosophy behind `kable` is to make it easy for programmers to use. Just as it claimed in its function description,
12> This is a very simple table generator. It is simple by design. It is not intended to replace any other R packages for making tables. - Yihui
Hao Zhub1bc0aa2015-11-12 11:23:42 -050013
Hao Zhu4adea852015-11-16 16:38:34 -050014However, we also see a lot of people getting frustrated online for the lack of functionality of `kable`. It is kind of unfair to `kable` as it is supposed to be "simple" by design. However, it is also understandable as people cry because they love to use this function instead of those complicated alternatives.
Hao Zhub1bc0aa2015-11-12 11:23:42 -050015
Hao Zhu4adea852015-11-16 16:38:34 -050016In `kableExtra`, we are not intended to build another table generator engine as there have been a lot (actually too many in my personal opinion) in `R`. This package is an attempt to extend `knitr::kable`'s functionality without destroying the beauty of its simplicity by using the pipe syntax from `magrittr`. We will follow the literal programming practice and try to make the progress of building a table in `R` go together with the flow of logic in your mind. We will also borrow the idea of *"grammar of graphics"* from `ggplot2` and `ggvis` and implement it in the progress of table generating tasks.
17
18##Vocabulary & Grammar
19Here is a list of features that we would love to see in this package. I bolded these that have been done.
20
21- **add_footnote()**
22- add_indent()
23- col_markup()
24- row_markup()
25- add_stripe()
26- add_hover()
27- add_textcolor()
28- add_bgcolor()
29- **magic_mirror()**
30- reverse_kable()
31
32The syntax of this package is just like what you are doing in `dplyr` or `ggvis`. Here is an example of adding footnote to a `kable` object.
33```r
34library(knitr)
35library(kableExtra)
36
37cars %>%
38 head() %>%
39 rename("speed[note]" = speed) %>%
40 kable(caption = "Head of cars [note]") %>%
41 add_footnote(
42 label = c("Footnote in caption",
43 "Footnote in table"),
44 notation = "number" # Or "alphabet"/"symbol"
45 )
46```