if (FALSE) { # knitr::is_html_output()
}
if (knitr::is_html_output()) options(tinytable_print_output = "html")
library(tinytable)
tt(mtcars[1:5, 1:6])
# Alignment
tt(mtcars[1:5, 1:6]) |>
style_tt(j = 1:5, align = "lcccr")
# Colors and styles
tt(mtcars[1:5, 1:6]) |>
style_tt(i = 2:3, background = "black", color = "orange", bold = TRUE)
# column selection with `j``
tt(mtcars[1:5, 1:6]) |>
style_tt(j = 5:6, background = "pink")
tt(mtcars[1:5, 1:6]) |>
style_tt(j = "drat|wt", background = "pink")
tt(mtcars[1:5, 1:6]) |>
style_tt(j = c("drat", "wt"), background = "pink")
tt(mtcars[1:5, 1:6], theme = "void") |>
style_tt(
i = 2, j = 2,
colspan = 3,
rowspan = 2,
align = "c",
alignv = "m",
color = "white",
background = "black",
bold = TRUE)
tt(mtcars[1:5, 1:6], theme = "void") |>
style_tt(
i = 0:3,
j = 1:3,
line = "tblr",
line_width = 0.4,
line_color = "teal")
tt(mtcars[1:5, 1:6], theme = "bootstrap") |>
style_tt(
i = c(2, 5),
j = 3,
strikeout = TRUE,
fontsize = 0.7)
tt(mtcars[1:5, 1:6]) |>
style_tt(bootstrap_class = "table table-dark table-hover")
inner <- "
column{1-4}={halign=c},
hlines = {fg=white},
vlines = {fg=white},
cell{1,6}{odd} = {bg=teal7},
cell{1,6}{even} = {bg=green7},
cell{2,4}{1,4} = {bg=red7},
cell{3,5}{1,4} = {bg=purple7},
cell{2}{2} = {r=4,c=2}{bg=azure7},
"
tt(mtcars[1:5, 1:4], theme = "void") |>
style_tt(tabularray_inner = inner)
Run the code above in your browser using DataLab