Hao Zhu | 971d89f | 2017-06-07 19:22:47 -0400 | [diff] [blame] | 1 | --- |
| 2 | title: "Untitled" |
Hao Zhu | a31e97f | 2017-06-08 14:55:41 -0400 | [diff] [blame] | 3 | output: |
| 4 | pdf_document: |
| 5 | keep_tex: true |
Hao Zhu | 971d89f | 2017-06-07 19:22:47 -0400 | [diff] [blame] | 6 | --- |
| 7 | |
Hao Zhu | 68d4fe9 | 2017-07-25 14:07:50 -0400 | [diff] [blame] | 8 | \listoftables |
| 9 | |
Hao Zhu | 971d89f | 2017-06-07 19:22:47 -0400 | [diff] [blame] | 10 | ```{r setup, include=FALSE} |
| 11 | knitr::opts_chunk$set(echo = TRUE) |
| 12 | ``` |
| 13 | |
| 14 | ```{r} |
| 15 | library(tidyverse) |
| 16 | library(knitr) |
| 17 | library(kableExtra) |
| 18 | |
Hao Zhu | ed84586 | 2017-08-03 09:24:08 -0400 | [diff] [blame] | 19 | dt <- rbind(mtcars[1:30,], mtcars) |
Hao Zhu | 971d89f | 2017-06-07 19:22:47 -0400 | [diff] [blame] | 20 | |
Hao Zhu | 7d4a3e3 | 2017-06-08 21:29:13 -0400 | [diff] [blame] | 21 | # kable(dt, "latex", longtable = T, caption="test table") %>% |
| 22 | # add_header_above(c(" ", "a" = 6, "b" = 5)) %>% |
| 23 | # kable_styling(latex_options = "repeat_header") |
Hao Zhu | 971d89f | 2017-06-07 19:22:47 -0400 | [diff] [blame] | 24 | ``` |
Hao Zhu | a31e97f | 2017-06-08 14:55:41 -0400 | [diff] [blame] | 25 | |
| 26 | ```{r} |
Hao Zhu | 245931c | 2017-09-01 22:43:56 -0400 | [diff] [blame] | 27 | kable(dt, "latex", longtable = T, caption = "test", booktabs = T, caption.short = "sss") %>% |
Hao Zhu | 6c9714a | 2017-10-02 14:52:45 -0400 | [diff] [blame] | 28 | kable_styling(latex_options = c("striped", "repeat_header"), |
| 29 | repeat_header_text = "(...)", repeat_header_continued = T) |
Hao Zhu | fdec184 | 2017-06-08 17:06:04 -0400 | [diff] [blame] | 30 | ``` |
| 31 | |
| 32 | ```{r} |
Hao Zhu | 6f95ea4 | 2017-07-25 13:12:12 -0400 | [diff] [blame] | 33 | kable(dt, "latex", longtable = T, caption = "test", booktabs = T) %>% |
| 34 | kable_styling(latex_options = c("striped", "repeat_header"), repeat_header_text = "continue of table 2", repeat_header_method = "replace") |
| 35 | ``` |
| 36 | |
| 37 | ```{r} |
Hao Zhu | fdec184 | 2017-06-08 17:06:04 -0400 | [diff] [blame] | 38 | kable(dt, "latex", longtable = T, booktabs = T) %>% |
| 39 | add_header_above(c(" ", "a" = 6, "b" = 5)) %>% |
Hao Zhu | 00ba87c | 2017-08-01 12:42:58 -0400 | [diff] [blame] | 40 | kable_styling(latex_options = c("striped", "repeat_header"), repeat_header_text = "(cont.)") |
Hao Zhu | a31e97f | 2017-06-08 14:55:41 -0400 | [diff] [blame] | 41 | ``` |
Hao Zhu | 2ce42b9 | 2017-06-15 17:15:33 -0400 | [diff] [blame] | 42 | |
| 43 | ```{r} |
| 44 | df <- data.frame(replicate(13, sample(1000000:9000000, 60,replace=TRUE))) |
| 45 | df$Sum <- rowSums(df) |
| 46 | totals <- colSums(df) |
| 47 | df <- rbind(df, totals) |
| 48 | names(df) <- c("Jan 2014", "Feb 2014", "Mar 2014", "Apr 2014", "May 2014", "Jun 2014", "Jul 2014", |
| 49 | "Aug 2014", "Sep 2014", "Oct 2014", "Nov 2014", "Dec 2014", "Jan 2015", "Sum") |
| 50 | kable(df, "latex", longtable = T, booktabs = T) %>% |
| 51 | kable_styling(latex_options = c("repeat_header"), font_size = 7) %>% |
| 52 | landscape() |
| 53 | ``` |