Hao Zhu | e414511 | 2015-11-05 17:52:59 -0500 | [diff] [blame] | 1 | --- |
| 2 | output: |
| 3 | md_document: |
| 4 | variant: markdown_github |
| 5 | --- |
| 6 | <!-- README.md is generated from README.Rmd. Please edit that file --> |
| 7 | |
Hao Zhu | db04e30 | 2015-11-15 16:57:38 -0500 | [diff] [blame] | 8 | This 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 Zhu | b1bc0aa | 2015-11-12 11:23:42 -0500 | [diff] [blame] | 9 | |
Hao Zhu | 4adea85 | 2015-11-16 16:38:34 -0500 | [diff] [blame] | 10 | #Introduction to kableExtra |
| 11 | When 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 Zhu | b1bc0aa | 2015-11-12 11:23:42 -0500 | [diff] [blame] | 13 | |
Hao Zhu | 4adea85 | 2015-11-16 16:38:34 -0500 | [diff] [blame] | 14 | However, 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 Zhu | b1bc0aa | 2015-11-12 11:23:42 -0500 | [diff] [blame] | 15 | |
Hao Zhu | 4adea85 | 2015-11-16 16:38:34 -0500 | [diff] [blame] | 16 | In `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 |
| 19 | Here 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 | |
| 32 | The 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 |
| 34 | library(knitr) |
| 35 | library(kableExtra) |
| 36 | |
| 37 | cars %>% |
| 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 | ``` |
Will Beasley | a3864bb | 2016-01-11 10:53:22 -0600 | [diff] [blame^] | 47 | |
| 48 | ## Examples |
| 49 | These two documents demonstrate the different behaviors under HTML and LaTeX (including booktabs and longtable) |
| 50 | |
| 51 | * [HTML demo](http://rpubs.com/haozhu233/kableExtra_footnote_html) |
| 52 | * [PDF demo](https://www.dropbox.com/s/qk7msi64mndn67y/brief_demo_pdf.pdf?dl=0) |