+ - 0:00:00
Notes for current slide
Notes for next slide

Publication/Presentation-ready Tables

Janani Ravi

Michigan State University + R-Ladies East Lansing

2021-05-09

1 / 17

Slides made with xaringan (Yihui Xie) and R-Ladies theme (Allison Hill).

2 / 17

Overview

3 / 17

GT

4 / 17

knitr

5 / 17

rmarkdown

6 / 17

DT & datatables

7 / 17

Explore later: flextable

8 / 17

Let's create a few cool tables!

9 / 17

Tables w/ knitr

If you want to generate a table, make sure it is in the HTML format (instead of Markdown or other formats), e.g.,

knitr::kable(head(iris), format = 'html')
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
5.1 3.5 1.4 0.2 setosa
4.9 3.0 1.4 0.2 setosa
4.7 3.2 1.3 0.2 setosa
4.6 3.1 1.5 0.2 setosa
5.0 3.6 1.4 0.2 setosa
5.4 3.9 1.7 0.4 setosa
10 / 17

Tables w/ rmarkdown

paged_table(iris)
ABCDEFGHIJ0123456789
Sepal.Length
<dbl>
Sepal.Width
<dbl>
Petal.Length
<dbl>
Petal.Width
<dbl>
Species
<fct>
5.13.51.40.2setosa
4.93.01.40.2setosa
4.73.21.30.2setosa
4.63.11.50.2setosa
5.03.61.40.2setosa
5.43.91.70.4setosa
4.63.41.40.3setosa
5.03.41.50.2setosa
4.42.91.40.2setosa
4.93.11.50.1setosa
11 / 17

Tables w/ kableExtra

iris %>% head %>%
kable(caption = "Table 1. Annotate with kableExtra") %>%
kable_styling(c("striped", "hover", "condensed"), full_width = F,
position = "left") %>%
add_header_above(c("categorical"=1, "numerical" = 4)) %>%
column_spec(1, bold = T) %>%
row_spec(0, italic = T)
Table 1. Annotate with kableExtra
categorical
numerical
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
5.1 3.5 1.4 0.2 setosa
4.9 3.0 1.4 0.2 setosa
4.7 3.2 1.3 0.2 setosa
4.6 3.1 1.5 0.2 setosa
5.0 3.6 1.4 0.2 setosa
5.4 3.9 1.7 0.4 setosa
12 / 17

Tables w/ gt

13 / 17

DT and datatable

iris %>% head() %>%
datatable(fillContainer=FALSE,
options=list(pageLength=8))
14 / 17

Thanks!



How to reach me?

Email: janani@msu.edu

Webpage: jravilab.github.io

Twitter: @janani137



Slides created via the R package xaringan (Yihui Xie) and R-Ladies theme (Allison Hill).

17 / 17

Slides made with xaringan (Yihui Xie) and R-Ladies theme (Allison Hill).

2 / 17
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow