Hao Zhu | 36bc508 | 2017-07-03 11:49:00 -0400 | [diff] [blame] | 1 | --- |
| 2 | title: "test_doc" |
| 3 | author: "Jake Thompson" |
| 4 | date: "6/30/2017" |
| 5 | output: |
| 6 | bookdown::pdf_document2: |
| 7 | toc: false |
| 8 | --- |
| 9 | |
| 10 | ```{r setup, include=FALSE} |
| 11 | knitr::opts_chunk$set(echo = FALSE, collapse = TRUE) |
| 12 | library(tidyverse) |
Hao Zhu | 443a71c | 2017-07-03 20:06:29 -0400 | [diff] [blame^] | 13 | library(knitr) |
| 14 | library(kableExtra) |
Hao Zhu | 36bc508 | 2017-07-03 11:49:00 -0400 | [diff] [blame] | 15 | ``` |
| 16 | |
| 17 | # Test heading |
| 18 | |
| 19 | Let make a data frame and print it in Table \@ref(tab:test-table) |
| 20 | |
| 21 | ```{r test-table} |
| 22 | data_frame(col_a = seq_len(5), col_b = rnorm(5), col_c = runif(5)) %>% |
| 23 | knitr::kable(caption = "This is a test") %>% |
Hao Zhu | 443a71c | 2017-07-03 20:06:29 -0400 | [diff] [blame^] | 24 | kableExtra::kable_styling(latex_options = "hold_position") %>% |
| 25 | column_spec(1, bold = T) %>% |
| 26 | collapse_rows() |
| 27 | ``` |
| 28 | |
| 29 | ```{r} |
| 30 | collapse_rows_dt <- data.frame(C1 = c(rep("a", 10), rep("b", 5)), |
| 31 | C2 = c(rep("c", 7), rep("d", 3), rep("c", 2), rep("d", 3)), |
| 32 | C3 = 1:15, |
| 33 | C4 = sample(c(0,1), 15, replace = TRUE)) |
| 34 | kable(collapse_rows_dt, "latex", booktabs = T, align = "c") %>% |
| 35 | column_spec(1, bold=T) %>% |
| 36 | collapse_rows(columns = 1:2) |
Hao Zhu | 36bc508 | 2017-07-03 11:49:00 -0400 | [diff] [blame] | 37 | ``` |