blob: d13f0d0df06227af805c5f92cc712191f2f1d9fe [file] [log] [blame]
Hao Zhu36bc5082017-07-03 11:49:00 -04001---
2title: "test_doc"
3author: "Jake Thompson"
4date: "6/30/2017"
5output:
6 bookdown::pdf_document2:
7 toc: false
8---
9
10```{r setup, include=FALSE}
11knitr::opts_chunk$set(echo = FALSE, collapse = TRUE)
12library(tidyverse)
Hao Zhu443a71c2017-07-03 20:06:29 -040013library(knitr)
14library(kableExtra)
Hao Zhu36bc5082017-07-03 11:49:00 -040015```
16
17# Test heading
18
19Let make a data frame and print it in Table \@ref(tab:test-table)
20
21```{r test-table}
22data_frame(col_a = seq_len(5), col_b = rnorm(5), col_c = runif(5)) %>%
23 knitr::kable(caption = "This is a test") %>%
Hao Zhu443a71c2017-07-03 20:06:29 -040024 kableExtra::kable_styling(latex_options = "hold_position") %>%
25 column_spec(1, bold = T) %>%
26 collapse_rows()
27```
28
29```{r}
30collapse_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))
34kable(collapse_rows_dt, "latex", booktabs = T, align = "c") %>%
35 column_spec(1, bold=T) %>%
36 collapse_rows(columns = 1:2)
Hao Zhu36bc5082017-07-03 11:49:00 -040037```