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