# NOT RUN {
# Use `gtcars` to create a gt table; add
# a stubhead label to describe what is
# in the stub
tab_1 <-
gtcars %>%
dplyr::select(model, year, hp, trq) %>%
dplyr::slice(1:5) %>%
gt(rowname_col = "model") %>%
tab_stubhead_label(label = "car")
# Get an HTML file with inlined CSS
# (which is necessary for including the
# table as part of an HTML email)
tab_1 %>%
gtsave("tab_1.html", inline_css = TRUE)
# By leaving out the `inline_css` option,
# we get a more conventional HTML file
# with embedded CSS styles
tab_1 %>% gtsave("tab_1.html")
# Save the HTML table as a PDF file; we
# can optionally add a separate `path`
tab_1 %>% gtsave("tab_1.pdf", path = "~")
# Saving as PNG file results in a cropped
# image of an HTML table; the amount of
# whitespace can be set
tab_1 %>% gtsave("tab_1.png", expand = 10)
# Any use of the `.tex`, `.ltx`, or `.rnw`
# will result in the output of a LaTeX
# document
tab_1 %>% gtsave("tab_1.tex")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab