<- data.frame(
- dat w = c(143002.2092, 201399.181, 100188.3883),
- x = c(1.43402, 201.399, 0.134588),
- y = as.Date(sample(1:1000, 3)),
- z = c(TRUE, TRUE, FALSE))
-
-tt(dat, digits = 2)
<- data.frame(
+ dat w = c(143002.2092, 201399.181, 100188.3883),
+ x = c(1.43402, 201.399, 0.134588),
+ y = as.Date(sample(1:1000, 3)),
+ z = c(TRUE, TRUE, FALSE))
+
+tt(dat, digits = 2)
Called from: tt_bootstrap(x = list(w = c("143002", "201399", "100188"), x = c(" 1.43",
+"201.40", " 0.13"), y = c("1971-06-01", "1971-03-08", "1971-04-25"
+), z = c("True", "True", "False")), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+Form
- tinytable_llzal9zd6wdh8l61i8ro
+ tinytable_384ihffp3wcku09li564
@@ -965,7 +1149,7 @@ Form
-
+
@@ -980,19 +1164,19 @@ Form
143002
1.43
- 1972-02-04
+ 1971-06-01
True
201399
201.40
- 1971-02-18
+ 1971-03-08
True
100188
0.13
- 1972-03-19
+ 1971-04-25
False
@@ -1001,12 +1185,12 @@ Form
@@ -1987,7 +2481,7 @@ Math
-
+
@@ -2008,12 +2502,12 @@ Math
@@ -2068,12 +2562,43 @@ Style
Cells, rows, columns
To style individual cells, we use the style_cell()
function. The first two arguments—i
and j
—identify the cells of interest, by row and column numbers respectively. To style a cell in the 2nd row and 3rd column, we can do:
-tt(x) |>
-style_tt(
- i = 2,
- j = 3,
- background = "black",
- color = "white")
+tt(x) |>
+style_tt(
+ i = 2,
+ j = 3,
+ background = "black",
+ color = "white")
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -2081,10 +2606,10 @@ Cells, rows, columns
- tinytable_7og5a7c63pudxq1gaag3
+ tinytable_qmip6x1cd1345mmfha6t
@@ -2102,7 +2627,7 @@ Cells, rows, columns
-
+
@@ -2149,12 +2674,12 @@ Cells, rows, columns
@@ -2180,12 +2705,43 @@ Cells, rows, columns
The i
and j
accept vectors of integers to modify several cells at once:
-tt(x) |>
-style_tt(
- i = 2:3,
- j = c(1, 3, 4),
- italic = TRUE,
- color = "orange")
+tt(x) |>
+style_tt(
+ i = 2:3,
+ j = c(1, 3, 4),
+ italic = TRUE,
+ color = "orange")
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -2193,10 +2749,10 @@ Cells, rows, columns
- tinytable_nm7a7m9bdbzjgb8xbx22
+ tinytable_0e3d8frmpdge8gae6slq
@@ -2214,7 +2770,7 @@ Cells, rows, columns
-
+
@@ -2261,12 +2817,12 @@ Cells, rows, columns
@@ -2297,7 +2853,38 @@ Cells, rows, columns
We can style all cells in a table by omitting both the i
and j
arguments:
-tt(x) |> style_tt(color = "orange")
+tt(x) |> style_tt(color = "orange")
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -2305,10 +2892,10 @@ Cells, rows, columns
- tinytable_l1r4l26rdy7j0fmz3oo4
+ tinytable_paciktzxipdmnqau17w4
@@ -2326,7 +2913,7 @@ Cells, rows, columns
-
+
@@ -2373,12 +2960,12 @@ Cells, rows, columns
@@ -2423,7 +3010,38 @@ Cells, rows, columns
We can style entire rows by omitting the j
argument:
-tt(x) |> style_tt(i = 1:2, color = "orange")
+tt(x) |> style_tt(i = 1:2, color = "orange")
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -2431,10 +3049,10 @@ Cells, rows, columns
- tinytable_o6jo63tw0rnl8cakahym
+ tinytable_gguzxf310z41emj1uadx
@@ -2452,7 +3070,7 @@ Cells, rows, columns
-
+
@@ -2499,12 +3117,12 @@ Cells, rows, columns
@@ -2539,7 +3157,38 @@ Cells, rows, columns
We can style entire columns by omitting the i
argument:
-tt(x) |> style_tt(j = c(2, 4), bold = TRUE)
+tt(x) |> style_tt(j = c(2, 4), bold = TRUE)
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -2547,10 +3196,10 @@ Cells, rows, columns
- tinytable_v5wfvuhqum2oikswz1ft
+ tinytable_iau5p13mjznznrlgil20
@@ -2568,7 +3217,7 @@ Cells, rows, columns
-
+
@@ -2615,12 +3264,12 @@ Cells, rows, columns
@@ -2655,7 +3304,38 @@ Cells, rows, columns
The j
argument accepts integer vectors, but also a string with a Perl-style regular expression, which makes it easier to select columns by name:
-tt(x) |> style_tt(j = "mpg|drat", color = "orange")
+tt(x) |> style_tt(j = "mpg|drat", color = "orange")
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -2663,10 +3343,10 @@ Cells, rows, columns
- tinytable_blvenw1eau9kkmag31sk
+ tinytable_ey88ffpqeu8kigftto6v
@@ -2684,7 +3364,7 @@ Cells, rows, columns
-
+
@@ -2731,12 +3411,12 @@ Cells, rows, columns
@@ -2771,9 +3451,40 @@ Cells, rows, columns
Of course, we can also call the style_tt()
function several times to apply different styles to different parts of the table:
-tt(x) |>
-style_tt(i = 1, j = 1:2, color = "orange") |>
- style_tt(i = 1, j = 3:4, color = "green")
+tt(x) |>
+style_tt(i = 1, j = 1:2, color = "orange") |>
+ style_tt(i = 1, j = 3:4, color = "green")
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -2781,11 +3492,11 @@ Cells, rows, columns
- tinytable_t8n8nqydhfncukf868nk
+ tinytable_mcz18amrpo48m704ct75
@@ -2803,7 +3514,7 @@ Cells, rows, columns
-
+
@@ -2850,12 +3561,12 @@ Cells, rows, columns
@@ -2900,7 +3611,38 @@ Colors
Note that the keywords used in LaTeX and HTML are slightly different.
-tt(x) |> style_tt(i = 1:4, j = 1, color = "#FF5733")
+tt(x) |> style_tt(i = 1:4, j = 1, color = "#FF5733")
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -2908,10 +3650,10 @@ Colors
- tinytable_9651j99i8bo06ln1vx3b
+ tinytable_xws1a0wnhpajp10lty11
@@ -2929,7 +3671,7 @@ Colors
-
+
@@ -2976,12 +3718,12 @@ Colors
@@ -3014,7 +3756,38 @@ Colors
Fonts
The font size is specified in terms of pt
units, where 1pt=1.333px:
-tt(x) |> style_tt(j = "mpg|hp|qsec", fontsize = 18)
+tt(x) |> style_tt(j = "mpg|hp|qsec", fontsize = 18)
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -3022,10 +3795,10 @@ Fonts
- tinytable_7cfmm97prqiwbw9exc8m
+ tinytable_mimwl8cs352g516a38l9
@@ -3043,7 +3816,7 @@ Fonts
-
+
@@ -3090,12 +3863,12 @@ Fonts
@@ -3133,9 +3906,38 @@ Fonts
Headers
The header can be omitted from the table by deleting the column names in the x
data frame:
-<- x
- k colnames(k) <- NULL
-tt(k)
+<- x
+ k colnames(k) <- NULL
+tt(k)
+
+Called from: tt_bootstrap(x = list(c(21, 21, 22.8, 21.4), c(6, 6, 4, 6), c(160,
+160, 108, 258), c(110, 110, 93, 110), c(3.9, 3.9, 3.85, 3.08)),
+ caption = NULL, theme = "default", width = NULL, notes = NULL,
+ placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- NULL
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -3143,7 +3945,7 @@ Headers
- tinytable_ka7ku5awcew6zj2ctnif
+ tinytable_bnlnhgmaguj0m36r1gu3
@@ -3163,7 +3965,7 @@ Headers
-
+
@@ -3203,12 +4005,12 @@ Headers
@@ -3263,7 +4096,7 @@ Headers
-
+
@@ -3310,12 +4143,12 @@ Headers
@@ -3345,7 +4178,38 @@ Headers
When styling columns without specifying i
, the headers are styled in accordance with the rest of the column:
-tt(x) |> style_tt(j = 2:3, color = "white", background = "black")
+tt(x) |> style_tt(j = 2:3, color = "white", background = "black")
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -3353,10 +4217,10 @@ Headers
- tinytable_mki6vz17gxtnmp9hgmca
+ tinytable_qp2la3kk98ta7vmst7sm
@@ -3374,7 +4238,7 @@ Headers
-
+
@@ -3421,12 +4285,12 @@ Headers
@@ -3464,13 +4328,44 @@ Headers
Conditional styling
We can use the standard which
function from Base R
to create indices and apply conditional stying on rows. And we can use a regular expression in j
to apply conditional styling on columns:
-<- mtcars[1:10, c("mpg", "am", "vs")]
- k
-tt(k) |>
-style_tt(
- i = which(k$am == k$vs),
- background = "teal",
- color = "white")
+<- mtcars[1:10, c("mpg", "am", "vs")]
+ k
+tt(k) |>
+style_tt(
+ i = which(k$am == k$vs),
+ background = "teal",
+ color = "white")
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4, 18.7, 18.1,
+14.3, 24.4, 22.8, 19.2), am = c(1, 1, 1, 0, 0, 0, 0, 0, 0, 0),
+ vs = c(0, 0, 1, 1, 0, 1, 0, 1, 1, 1)), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -3478,10 +4373,10 @@ Conditional styling
- tinytable_03cjh33ruuv8bsfare3b
+ tinytable_v2wuq4qjazovxfu0pvoy
@@ -3499,7 +4394,7 @@ Conditional styling
-
+
@@ -3566,12 +4461,12 @@ Conditional styling
@@ -3608,10 +4503,41 @@ Conditional stylingVectorized styling (heatmaps)
The color
, background
, and fontsize
arguments are vectorized. This allows easy specification of different colors in a single call:
-tt(x) |>
-style_tt(
- i = 1:4,
- color = c("red", "blue", "green", "orange"))
+tt(x) |>
+style_tt(
+ i = 1:4,
+ color = c("red", "blue", "green", "orange"))
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -3619,13 +4545,13 @@ Vectorized sty
- tinytable_w8tpe5oqjoe0o7bsqslt
+ tinytable_swot6zjxeaxpmc266zdg
@@ -3643,7 +4569,7 @@ Vectorized sty
-
+
@@ -3690,12 +4616,12 @@ Vectorized sty
@@ -3740,11 +4666,42 @@ Vectorized sty
When using a single value for a vectorized argument, it gets applied to all values:
-tt(x) |>
-style_tt(
- j = 2:3,
- color = c("orange", "green"),
- background = "black")
+tt(x) |>
+style_tt(
+ j = 2:3,
+ color = c("orange", "green"),
+ background = "black")
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "default",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -3752,11 +4709,11 @@ Vectorized sty
- tinytable_zj2vuejphp98lxhvfg73
+ tinytable_knuzs2apt8bqxizpxqso
@@ -3774,7 +4731,7 @@ Vectorized sty
-
+
@@ -3821,12 +4778,12 @@ Vectorized sty
@@ -3861,23 +4818,50 @@ Vectorized sty
We can also produce more complex heatmap-like tables:
-# A table without header
-<- data.frame(matrix(1:20, ncol = 5))
- k colnames(k) <- NULL
-
-# 20 levels of Inferno colors
-<- hcl.colors(20, "Inferno")
- bg <- ifelse(as.matrix(k) < 17, tail(bg, 1), head(bg, 1))
- fg <- 1:20
- fs
-tt(k, width = .5, theme = "void") |>
-style_tt(j = 1:5, align = "ccccc") |>
- style_tt(
- i = 1:4,
- j = 1:5,
- color = fg,
- background = bg,
- fontsize = fs)
+# A table without header
+<- data.frame(matrix(1:20, ncol = 5))
+ k colnames(k) <- NULL
+
+# 20 levels of Inferno colors
+<- hcl.colors(20, "Inferno")
+ bg <- ifelse(as.matrix(k) < 17, tail(bg, 1), head(bg, 1))
+ fg <- 1:20
+ fs
+tt(k, width = .5, theme = "void") |>
+style_tt(j = 1:5, align = "ccccc") |>
+ style_tt(
+ i = 1:4,
+ j = 1:5,
+ color = fg,
+ background = bg,
+ fontsize = fs)
+
+Called from: tt_bootstrap(x = list(1:4, 5:8, 9:12, 13:16, 17:20), caption = NULL,
+ theme = "void", width = 0.5, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- NULL
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -3885,30 +4869,30 @@ Vectorized sty
- tinytable_a864wd56378ohrrms4ur
+ tinytable_w9yynimtbvp2agj4ru29
@@ -3926,7 +4910,7 @@ Vectorized sty
-
+
@@ -3966,12 +4950,12 @@ Vectorized sty
@@ -4043,13 +5027,49 @@ Groups and labels
Rows
The i
argument accepts a named list of integers. The numbers identify the positions where row group labels are to be inserted. The names includes the text that should be inserted:
-<- mtcars[1:9, 1:8]
- dat
-tt(dat) |>
-group_tt(i = list(
- "I like (fake) hamburgers" = 3,
- "She prefers halloumi" = 4,
- "They love tofu" = 7))
+<- mtcars[1:9, 1:8]
+ dat
+tt(dat) |>
+group_tt(i = list(
+ "I like (fake) hamburgers" = 3,
+ "She prefers halloumi" = 4,
+ "They love tofu" = 7))
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4, 18.7, 18.1,
+14.3, 24.4, 22.8), cyl = c(6, 6, 4, 6, 8, 6, 8, 4, 4), disp = c(160,
+160, 108, 258, 360, 225, 360, 146.7, 140.8), hp = c(110, 110,
+93, 110, 175, 105, 245, 62, 95), drat = c(3.9, 3.9, 3.85, 3.08,
+3.15, 2.76, 3.21, 3.69, 3.92), wt = c(2.62, 2.875, 2.32, 3.215,
+3.44, 3.46, 3.57, 3.19, 3.15), qsec = c(16.46, 17.02, 18.61,
+19.44, 17.02, 20.22, 15.84, 20, 22.9), vs = c(0, 0, 1, 1, 0,
+1, 0, 1, 1)), caption = NULL, theme = "default", width = NULL,
+ notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -4057,11 +5077,11 @@ Rows
- tinytable_lsnvlhbhyai1ihbg5gz3
+ tinytable_9o8ch3av4vjkved6lcsf
@@ -4079,7 +5099,7 @@ Rows
-
+
@@ -4191,20 +5211,20 @@ Rows
@@ -4244,18 +5264,54 @@ Rows
We can style group rows in the same way as regular rows:
-tt(dat) |>
-group_tt(
- i = list(
- "I like (fake) hamburgers" = 3,
- "She prefers halloumi" = 4,
- "They love tofu" = 7)) |>
- style_tt(
- i = c(3, 5, 9),
- align = "c",
- color = "white",
- background = "gray",
- bold = TRUE)
+tt(dat) |>
+group_tt(
+ i = list(
+ "I like (fake) hamburgers" = 3,
+ "She prefers halloumi" = 4,
+ "They love tofu" = 7)) |>
+ style_tt(
+ i = c(3, 5, 9),
+ align = "c",
+ color = "white",
+ background = "gray",
+ bold = TRUE)
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4, 18.7, 18.1,
+14.3, 24.4, 22.8), cyl = c(6, 6, 4, 6, 8, 6, 8, 4, 4), disp = c(160,
+160, 108, 258, 360, 225, 360, 146.7, 140.8), hp = c(110, 110,
+93, 110, 175, 105, 245, 62, 95), drat = c(3.9, 3.9, 3.85, 3.08,
+3.15, 2.76, 3.21, 3.69, 3.92), wt = c(2.62, 2.875, 2.32, 3.215,
+3.44, 3.46, 3.57, 3.19, 3.15), qsec = c(16.46, 17.02, 18.61,
+19.44, 17.02, 20.22, 15.84, 20, 22.9), vs = c(0, 0, 1, 1, 0,
+1, 0, 1, 1)), caption = NULL, theme = "default", width = NULL,
+ notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -4263,12 +5319,12 @@ Rows
- tinytable_dlfrp2ew7xxh97f3ejpu
+ tinytable_2ghcsme827glsskyrslp
@@ -4286,7 +5342,7 @@ Rows
-
+
@@ -4398,20 +5454,20 @@ Rows
@@ -4478,12 +5534,48 @@ Rows
Columns
The syntax for column groups is very similar, but we use the j
argument instead. The named list specifies the labels to appear in column-spanning labels, and the values must be a vector of consecutive and non-overlapping integers that indicate which columns are associated to which labels:
-tt(dat) |>
-group_tt(
- j = list(
- "Hamburgers" = 1:3,
- "Halloumi" = 4:5,
- "Tofu" = 7))
+tt(dat) |>
+group_tt(
+ j = list(
+ "Hamburgers" = 1:3,
+ "Halloumi" = 4:5,
+ "Tofu" = 7))
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4, 18.7, 18.1,
+14.3, 24.4, 22.8), cyl = c(6, 6, 4, 6, 8, 6, 8, 4, 4), disp = c(160,
+160, 108, 258, 360, 225, 360, 146.7, 140.8), hp = c(110, 110,
+93, 110, 175, 105, 245, 62, 95), drat = c(3.9, 3.9, 3.85, 3.08,
+3.15, 2.76, 3.21, 3.69, 3.92), wt = c(2.62, 2.875, 2.32, 3.215,
+3.44, 3.46, 3.57, 3.19, 3.15), qsec = c(16.46, 17.02, 18.61,
+19.44, 17.02, 20.22, 15.84, 20, 22.9), vs = c(0, 0, 1, 1, 0,
+1, 0, 1, 1)), caption = NULL, theme = "default", width = NULL,
+ notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -4491,7 +5583,7 @@ Columns
- tinytable_oeor1ga4wpib6xhognsa
+ tinytable_zkcxa99a5ldy1t665ykm
@@ -4511,7 +5603,7 @@ Columns
-
+
Hamburgers
Halloumi
@@ -4628,12 +5720,12 @@ Columns
@@ -4704,7 +5832,7 @@ Columns
-
+
Hamburgers
Halloumi
@@ -4821,20 +5949,20 @@ Columns
@@ -4913,7 +6041,38 @@ Themes
The Bootstrap framework provides a number of built-in themes to style tables. To use them, we call bootstrapOptions()
with the class
argument, and we specify the Bootstrap class. A list of available Bootstrap classes can be found here: https://getbootstrap.com/docs/5.3/content/tables/
For example, to produce a “dark” table, we use the table-dark
class:
-tt(x, theme = "table table-dark")
+tt(x, theme = "table table-dark")
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "table table-dark",
+ width = NULL, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -4921,7 +6080,7 @@ Themes
- tinytable_bvwg21kh369vtdkozjfm
+ tinytable_ehjb3wi17lqtl78rok9v
@@ -4941,7 +6100,7 @@ Themes
-
+
@@ -4988,12 +6147,12 @@ Themes
@@ -5158,7 +6379,7 @@ CSS declarations
-
+
@@ -5205,12 +6426,12 @@ CSS declarations
@@ -5243,43 +6464,74 @@ CSS declarations
CSS rules
For more extensive customization, we can use complete CSS rules. In this example, we define several rules that apply to a new class called mytable
. Then, we use the theme
argument of the tt()
function to ensure that our tiny table is of class mytable
. Finally, we call style_bootstrap()
to apply the rules with the bootstrap_css_rule
argument.
-<- "
- css_rule .mytable {
- background: linear-gradient(45deg, #EA8D8D, #A890FE);
- width: 600px;
- border-collapse: collapse;
- overflow: hidden;
- box-shadow: 0 0 20px rgba(0,0,0,0.1);
-}
-
-.mytable th,
-.mytable td {
- padding: 5px;
- background-color: rgba(255,255,255,0.2);
- color: #fff;
-}
-
-.mytable tbody tr:hover {
- background-color: rgba(255,255,255,0.3);
-}
-
-.mytable tbody td:hover:before {
- content: '';
- position: absolute;
- left: 0;
- right: 0;
- top: -9999px;
- bottom: -9999px;
- background-color: rgba(255,255,255,0.2);
- z-index: -1;
-}
-"
-
-tt(x, theme = "table mytable", width = 2/3) |>
-style_tt(
- j = 1:5,
- align = "ccccc",
- bootstrap_css_rule = css_rule)
+<- "
+ css_rule .mytable {
+ background: linear-gradient(45deg, #EA8D8D, #A890FE);
+ width: 600px;
+ border-collapse: collapse;
+ overflow: hidden;
+ box-shadow: 0 0 20px rgba(0,0,0,0.1);
+}
+
+.mytable th,
+.mytable td {
+ padding: 5px;
+ background-color: rgba(255,255,255,0.2);
+ color: #fff;
+}
+
+.mytable tbody tr:hover {
+ background-color: rgba(255,255,255,0.3);
+}
+
+.mytable tbody td:hover:before {
+ content: '';
+ position: absolute;
+ left: 0;
+ right: 0;
+ top: -9999px;
+ bottom: -9999px;
+ background-color: rgba(255,255,255,0.2);
+ z-index: -1;
+}
+"
+
+tt(x, theme = "table mytable", width = 2/3) |>
+style_tt(
+ j = 1:5,
+ align = "ccccc",
+ bootstrap_css_rule = css_rule)
+
+Called from: tt_bootstrap(x = list(mpg = c(21, 21, 22.8, 21.4), cyl = c(6,
+6, 4, 6), disp = c(160, 160, 108, 258), hp = c(110, 110, 93,
+110), drat = c(3.9, 3.9, 3.85, 3.08)), caption = NULL, theme = "table mytable",
+ width = 0.666666666666667, notes = NULL, placement = "H")
+debug: idx <- grep("$tinytable_BOOTSTRAP_HEADER", template, fixed = TRUE)
+debug: if (!is.null(colnames(x))) {
+ header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+ header <- c(" <tr>", header, " </tr>")
+ header <- paste(strrep(" ", 11), header)
+} else {
+ header <- NULL
+}
+debug: header <- sprintf(" <th scope=\"col\">%s</th>", colnames(x))
+debug: header <- c(" <tr>", header, " </tr>")
+debug: header <- paste(strrep(" ", 11), header)
+debug: template <- c(template[1:(idx - 1)], header, template[(idx +
+ 1):length(template)])
+debug: makerow <- function(x) {
+ out <- c(" <tr>", sprintf(" <td>%s</td>", x), " </tr>")
+ return(out)
+}
+debug: body <- apply(x, 1, makerow)
+debug: idx <- grep("$tinytable_BOOTSTRAP_BODY", template, fixed = TRUE)
+debug: template <- c(template[1:(idx - 1)], paste(strrep(" ", 13), body),
+ template[(idx + 1):length(template)])
+debug: out <- paste(template, collapse = "\n")
+debug: class(out) <- c("tinytable", "knit_asis", class(out))
+debug: attr(out, "tinytable_meta") <- m
+debug: return(out)
+
@@ -5287,10 +6539,10 @@ CSS rules
- tinytable_1hoxbtijo8r4clbcypmq
+ tinytable_zodr4colt2t4mazs5rog
143002 | 1.43 | -1972-02-04 | +1971-06-01 | True | ||||||||||||||||||||
201399 | 201.40 | -1971-02-18 | +1971-03-08 | True | ||||||||||||||||||||
100188 | 0.13 | -1972-03-19 | +1971-04-25 | False |
Hamburgers | Halloumi | @@ -4628,12 +5720,12 @@
---|
Hamburgers | Halloumi | @@ -4821,20 +5949,20 @@
---|