diff --git a/man/format_tt.html b/man/format_tt.html
index a1fd8ed8..22f0cb0d 100644
--- a/man/format_tt.html
+++ b/man/format_tt.html
@@ -701,12 +701,12 @@
Examples
-
+
@@ -760,16 +760,16 @@ Examples
- 10 000 |
9 999 |
+ 10 002 |
- 9 999 |
- 10 001 |
+ 10 000 |
+ 10 002 |
10 002 |
- 9 999 |
+ 10 000 |
@@ -782,12 +782,12 @@ Examples
-
+
@@ -861,12 +861,12 @@ Examples
-
+
@@ -952,12 +952,12 @@ Examples
-
+
@@ -1025,12 +1025,12 @@ Examples
-
+
@@ -1098,12 +1098,12 @@ Examples
-
+
@@ -1182,12 +1182,12 @@ Examples
-
+
diff --git a/man/group_tt.html b/man/group_tt.html
index 84df0f7d..582878f0 100644
--- a/man/group_tt.html
+++ b/man/group_tt.html
@@ -480,12 +480,12 @@ Examples
-
+
@@ -555,36 +555,36 @@ Examples
- -1.0078862 |
- 0.4352756 |
+ -1.2928994 |
+ 0.3438932 |
- 1.4752168 |
- 0.9104151 |
+ -0.2131877 |
+ 0.9079434 |
- -0.8107267 |
- -0.2365799 |
+ -1.0560067 |
+ 0.8225227 |
- -1.2232999 |
- 0.1458874 |
+ 1.0793180 |
+ -1.9694722 |
- 0.9005819 |
- -0.6132735 |
+ -0.0945106 |
+ 0.5980063 |
- -0.1360992 |
- -1.1905177 |
+ 1.8215610 |
+ 0.2414946 |
- -0.6259448 |
- -1.0824529 |
+ 1.1239596 |
+ 1.0194036 |
- 0.6234085 |
- 0.3027523 |
+ -1.6838725 |
+ -1.0095785 |
@@ -604,12 +604,12 @@ Examples
-
+
|
@@ -778,12 +778,12 @@ Examples
-
+
@@ -975,12 +975,12 @@ Examples
-
+
Hamburgers |
@@ -1165,12 +1165,12 @@ Examples
-
+
Foo |
diff --git a/man/rbind2-tinytable-tinytable-method.html b/man/rbind2-tinytable-tinytable-method.html
index 092bbcda..2b7dbade 100644
--- a/man/rbind2-tinytable-tinytable-method.html
+++ b/man/rbind2-tinytable-tinytable-method.html
@@ -487,12 +487,12 @@ Examples
-
+
Combine two tiny tables.
@@ -603,12 +603,12 @@ Examples
-
+
Combine two tiny tables.
@@ -720,12 +720,12 @@ Examples
-
+
Combine two tiny tables.
@@ -830,12 +830,12 @@ Examples
-
+
Combine two tiny tables.
diff --git a/man/theme_tt.html b/man/theme_tt.html
index cce41cff..5bee552d 100644
--- a/man/theme_tt.html
+++ b/man/theme_tt.html
@@ -575,12 +575,12 @@ Examples
-
+
diff --git a/man/tt.html b/man/tt.html
index 2e3e1c84..68a093cd 100644
--- a/man/tt.html
+++ b/man/tt.html
@@ -632,12 +632,12 @@ Examples
-
+
@@ -737,12 +737,12 @@ Examples
-
+
@@ -965,12 +965,12 @@ Examples
-
+
diff --git a/search.json b/search.json
index 1b886dfe..8eaa7ba9 100644
--- a/search.json
+++ b/search.json
@@ -76,7 +76,7 @@
"href": "man/format_tt.html",
"title": "tinytable",
"section": "",
- "text": "This function formats the columns of a data frame based on the column type (logical, date, numeric). It allows various formatting options like significant digits, decimal points, and scientific notation. It also includes custom formatting for date and boolean values. If this function is applied several times to the same cell, the last transformation is retained and the previous calls are ignored, except for the escape argument which can be applied to previously transformed data.\n\n\n\nformat_tt(\n x,\n i = NULL,\n j = NULL,\n digits = get_option(\"tinytable_format_digits\", default = NULL),\n num_fmt = get_option(\"tinytable_format_num_fmt\", default = \"significant\"),\n num_zero = get_option(\"tinytable_format_num_zero\", default = FALSE),\n num_suffix = get_option(\"tinytable_format_num_suffix\", default = FALSE),\n num_mark_big = get_option(\"tinytable_format_num_mark_big\", default = \"\"),\n num_mark_dec = get_option(\"tinytable_format_num_mark_dec\", default =\n getOption(\"OutDec\", default = \".\")),\n date = get_option(\"tinytable_format_date\", default = \"%Y-%m-%d\"),\n bool = get_option(\"tinytable_format_bool\", default = function(column)\n tools::toTitleCase(tolower(column))),\n math = get_option(\"tinytable_format_math\", default = FALSE),\n other = get_option(\"tinytable_format_other\", default = as.character),\n replace = get_option(\"tinytable_format_replace\", default = TRUE),\n escape = get_option(\"tinytable_format_escape\", default = FALSE),\n markdown = get_option(\"tinytable_format_markdown\", default = FALSE),\n quarto = get_option(\"tinytable_format_quarto\", default = FALSE),\n fn = get_option(\"tinytable_format_fn\", default = NULL),\n sprintf = get_option(\"tinytable_format_sprintf\", default = NULL),\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA data frame or a vector to be formatted.\n\n\n\n\ni\n\n\nRow indices where the formatting should be applied.\n\n\n\n\nj\n\n\nColumn indices where the styling should be applied. Can be:\n\n\nInteger vectors indicating column positions.\n\n\nCharacter vector indicating column names.\n\n\nA single string specifying a Perl-style regular expression used to match column names.\n\n\n\n\n\n\ndigits\n\n\nNumber of significant digits or decimal places.\n\n\n\n\nnum_fmt\n\n\nThe format for numeric values; one of ‘significant’, ‘significant_cell’, ‘decimal’, or ‘scientific’.\n\n\n\n\nnum_zero\n\n\nLogical; if TRUE, trailing zeros are kept in \"decimal\" format (but not in \"significant\" format).\n\n\n\n\nnum_suffix\n\n\nLogical; if TRUE display short numbers with digits significant digits and K (thousands), M (millions), B (billions), or T (trillions) suffixes.\n\n\n\n\nnum_mark_big\n\n\nCharacter to use as a thousands separator.\n\n\n\n\nnum_mark_dec\n\n\nDecimal mark character. Default is the global option ‘OutDec’.\n\n\n\n\ndate\n\n\nA string passed to the format() function, such as \"%Y-%m-%d\". See the \"Details\" section in ?strptime\n\n\n\n\nbool\n\n\nA function to format logical columns. Defaults to title case.\n\n\n\n\nmath\n\n\nLogical. If TRUE, wrap cell values in math mode $..$. This is useful for LaTeX output or with HTML MathJax options(tinytable_html_mathjax=TRUE).\n\n\n\n\nother\n\n\nA function to format columns of other types. Defaults to as.character().\n\n\n\n\nreplace\n\n\nLogical, String or Named list of vectors\n\n\nTRUE: Replace NA by an empty string.\n\n\nFALSE: Print NA as the string \"NA\".\n\n\nString: Replace NA entries by the user-supplied string.\n\n\nNamed list: Replace matching elements of the vectors in the list by theirs names. Example:\n\n\nlist(“-” = c(NA, NaN), “Tiny” = -Inf, “Massive” = Inf)\n\n\n\n\n\n\n\n\nescape\n\n\nLogical or \"latex\" or \"html\". If TRUE, escape special characters to display them as text in the format of the output of a tt() table.\n\n\nIf i and j are both NULL, escape all cells, column names, caption, notes, and spanning labels created by group_tt().\n\n\n\n\n\n\nmarkdown\n\n\nLogical; if TRUE, render markdown syntax in cells. Ex: italicized text is properly italicized in HTML and LaTeX.\n\n\n\n\nquarto\n\n\nLogical. Enable Quarto data processing and wrap cell content in a data-qmd span (HTML) or macro (LaTeX). See warnings in the Global Options section below.\n\n\n\n\nfn\n\n\nFunction for custom formatting. Accepts a vector and returns a character vector of the same length.\n\n\n\n\nsprintf\n\n\nString passed to the ?sprintf function to format numbers or interpolate strings with a user-defined pattern (similar to the glue package, but using Base R).\n\n\n\n\n…\n\n\nAdditional arguments are ignored.\n\n\n\n\n\n\nA data frame with formatted columns.\n\n\n\n\n\n\n\noptions(“tinytable_quarto_figure” = FALSE): Typst only. Normally, it is best to allow Quarto to define the figure environment, so the default behavior is to not include one.\n\n\n\nThe format_tt(quarto=TRUE) argument activates Quarto data processing for specific cells. This funcationality comes with a few warnings:\n\n\nCurrently, Quarto provides a LaTeX macro, but it does not appear to do anything with it. References and markdown codes may not be processed as expected in LaTeX.\n\n\nQuarto data processing can enter in conflict with tinytable styling or formatting options. See below for how to disable it.\n\n\noptions(tinytable_quarto_disable_processing = TRUE)\nDisable Quarto processing of cell content. Setting this global option to FALSE may lead to conflicts with some tinytable features, but it also allows use of markdown and Quarto-specific code in table cells, such as cross-references.\n\nx <- data.frame(Math = \"x^2^\", Citation = \"@Lovelace1842\")\nfn <- function(z) sprintf(\"<span data-qmd='%s'></span>\", z)\ntt(x) |> format_tt(i = 1, fn = fn)\n\n\nSee this link for more details: https://quarto.org/docs/authoring/tables.html#disabling-quarto-table-processing\n\n\n\noptions(tinytable_html_mathjax = TRUE): insert MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\noptions(tinytable_html_portable = TRUE): plot_tt() inserts base 64 encoded images directly in the HTML file rather than use external links.\n\n\n\n\n\noptions(tinytable_pdf_clean = TRUE) deletes temporary and log files.\n\n\noptions(tinytable_pdf_engine = “xelatex”): \"xelatex\", \"pdflatex\", \"lualatex\"\n\n\n\n\n\n\nlibrary(\"tinytable\")\n\ndat <- data.frame(\n a = rnorm(3, mean = 10000),\n b = rnorm(3, 10000))\ntab <- tt(dat)\nformat_tt(tab,\n digits = 2,\n num_mark_dec = \",\",\n num_mark_big = \" \")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 10 000\n 9 999\n \n \n 9 999\n 10 001\n \n \n 10 002\n 9 999\n \n \n \n \n\n\nk <- tt(data.frame(x = c(0.000123456789, 12.4356789)))\nformat_tt(k, digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1, num_fmt = \"decimal\", num_zero = TRUE) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.4\n 99T\n \n \n Food: Halloumi\n 201.4\n 7.3B\n \n \n Food: Tofu\n 0.1\n 29M\n \n \n Food: Beans\n 0.0\n 94K\n \n \n \n \n\n\ny <- tt(data.frame(x = c(123456789.678, 12435.6789)))\nformat_tt(y, digits=3, num_mark_big=\" \")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 123 456 790\n \n \n 12 436\n \n \n \n \n\n\nx <- tt(data.frame(Text = c(\"_italicized text_\", \"__bold text__\")))\nformat_tt(x, markdown=TRUE)\n\n\n\n \n\n \n \n \n \n \n \n Text\n \n \n \n \n \n italicized text\n \n \n bold text\n \n \n \n \n\n\ntab <- data.frame(a = c(NA, 1, 2), b = c(3, NA, 5))\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\ndat <- data.frame(\n \"LaTeX\" = c(\"Dollars $\", \"Percent %\", \"Underscore _\"),\n \"HTML\" = c(\"<br>\", \"<sup>4</sup>\", \"<emph>blah</emph>\")\n)\ntt(dat) |> format_tt(escape = TRUE) \n\n\n\n \n\n \n \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>",
+ "text": "This function formats the columns of a data frame based on the column type (logical, date, numeric). It allows various formatting options like significant digits, decimal points, and scientific notation. It also includes custom formatting for date and boolean values. If this function is applied several times to the same cell, the last transformation is retained and the previous calls are ignored, except for the escape argument which can be applied to previously transformed data.\n\n\n\nformat_tt(\n x,\n i = NULL,\n j = NULL,\n digits = get_option(\"tinytable_format_digits\", default = NULL),\n num_fmt = get_option(\"tinytable_format_num_fmt\", default = \"significant\"),\n num_zero = get_option(\"tinytable_format_num_zero\", default = FALSE),\n num_suffix = get_option(\"tinytable_format_num_suffix\", default = FALSE),\n num_mark_big = get_option(\"tinytable_format_num_mark_big\", default = \"\"),\n num_mark_dec = get_option(\"tinytable_format_num_mark_dec\", default =\n getOption(\"OutDec\", default = \".\")),\n date = get_option(\"tinytable_format_date\", default = \"%Y-%m-%d\"),\n bool = get_option(\"tinytable_format_bool\", default = function(column)\n tools::toTitleCase(tolower(column))),\n math = get_option(\"tinytable_format_math\", default = FALSE),\n other = get_option(\"tinytable_format_other\", default = as.character),\n replace = get_option(\"tinytable_format_replace\", default = TRUE),\n escape = get_option(\"tinytable_format_escape\", default = FALSE),\n markdown = get_option(\"tinytable_format_markdown\", default = FALSE),\n quarto = get_option(\"tinytable_format_quarto\", default = FALSE),\n fn = get_option(\"tinytable_format_fn\", default = NULL),\n sprintf = get_option(\"tinytable_format_sprintf\", default = NULL),\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA data frame or a vector to be formatted.\n\n\n\n\ni\n\n\nRow indices where the formatting should be applied.\n\n\n\n\nj\n\n\nColumn indices where the styling should be applied. Can be:\n\n\nInteger vectors indicating column positions.\n\n\nCharacter vector indicating column names.\n\n\nA single string specifying a Perl-style regular expression used to match column names.\n\n\n\n\n\n\ndigits\n\n\nNumber of significant digits or decimal places.\n\n\n\n\nnum_fmt\n\n\nThe format for numeric values; one of ‘significant’, ‘significant_cell’, ‘decimal’, or ‘scientific’.\n\n\n\n\nnum_zero\n\n\nLogical; if TRUE, trailing zeros are kept in \"decimal\" format (but not in \"significant\" format).\n\n\n\n\nnum_suffix\n\n\nLogical; if TRUE display short numbers with digits significant digits and K (thousands), M (millions), B (billions), or T (trillions) suffixes.\n\n\n\n\nnum_mark_big\n\n\nCharacter to use as a thousands separator.\n\n\n\n\nnum_mark_dec\n\n\nDecimal mark character. Default is the global option ‘OutDec’.\n\n\n\n\ndate\n\n\nA string passed to the format() function, such as \"%Y-%m-%d\". See the \"Details\" section in ?strptime\n\n\n\n\nbool\n\n\nA function to format logical columns. Defaults to title case.\n\n\n\n\nmath\n\n\nLogical. If TRUE, wrap cell values in math mode $..$. This is useful for LaTeX output or with HTML MathJax options(tinytable_html_mathjax=TRUE).\n\n\n\n\nother\n\n\nA function to format columns of other types. Defaults to as.character().\n\n\n\n\nreplace\n\n\nLogical, String or Named list of vectors\n\n\nTRUE: Replace NA by an empty string.\n\n\nFALSE: Print NA as the string \"NA\".\n\n\nString: Replace NA entries by the user-supplied string.\n\n\nNamed list: Replace matching elements of the vectors in the list by theirs names. Example:\n\n\nlist(“-” = c(NA, NaN), “Tiny” = -Inf, “Massive” = Inf)\n\n\n\n\n\n\n\n\nescape\n\n\nLogical or \"latex\" or \"html\". If TRUE, escape special characters to display them as text in the format of the output of a tt() table.\n\n\nIf i and j are both NULL, escape all cells, column names, caption, notes, and spanning labels created by group_tt().\n\n\n\n\n\n\nmarkdown\n\n\nLogical; if TRUE, render markdown syntax in cells. Ex: italicized text is properly italicized in HTML and LaTeX.\n\n\n\n\nquarto\n\n\nLogical. Enable Quarto data processing and wrap cell content in a data-qmd span (HTML) or macro (LaTeX). See warnings in the Global Options section below.\n\n\n\n\nfn\n\n\nFunction for custom formatting. Accepts a vector and returns a character vector of the same length.\n\n\n\n\nsprintf\n\n\nString passed to the ?sprintf function to format numbers or interpolate strings with a user-defined pattern (similar to the glue package, but using Base R).\n\n\n\n\n…\n\n\nAdditional arguments are ignored.\n\n\n\n\n\n\nA data frame with formatted columns.\n\n\n\n\n\n\n\noptions(“tinytable_quarto_figure” = FALSE): Typst only. Normally, it is best to allow Quarto to define the figure environment, so the default behavior is to not include one.\n\n\n\nThe format_tt(quarto=TRUE) argument activates Quarto data processing for specific cells. This funcationality comes with a few warnings:\n\n\nCurrently, Quarto provides a LaTeX macro, but it does not appear to do anything with it. References and markdown codes may not be processed as expected in LaTeX.\n\n\nQuarto data processing can enter in conflict with tinytable styling or formatting options. See below for how to disable it.\n\n\noptions(tinytable_quarto_disable_processing = TRUE)\nDisable Quarto processing of cell content. Setting this global option to FALSE may lead to conflicts with some tinytable features, but it also allows use of markdown and Quarto-specific code in table cells, such as cross-references.\n\nx <- data.frame(Math = \"x^2^\", Citation = \"@Lovelace1842\")\nfn <- function(z) sprintf(\"<span data-qmd='%s'></span>\", z)\ntt(x) |> format_tt(i = 1, fn = fn)\n\n\nSee this link for more details: https://quarto.org/docs/authoring/tables.html#disabling-quarto-table-processing\n\n\n\noptions(tinytable_html_mathjax = TRUE): insert MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\noptions(tinytable_html_portable = TRUE): plot_tt() inserts base 64 encoded images directly in the HTML file rather than use external links.\n\n\n\n\n\noptions(tinytable_pdf_clean = TRUE) deletes temporary and log files.\n\n\noptions(tinytable_pdf_engine = “xelatex”): \"xelatex\", \"pdflatex\", \"lualatex\"\n\n\n\n\n\n\nlibrary(\"tinytable\")\n\ndat <- data.frame(\n a = rnorm(3, mean = 10000),\n b = rnorm(3, 10000))\ntab <- tt(dat)\nformat_tt(tab,\n digits = 2,\n num_mark_dec = \",\",\n num_mark_big = \" \")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 9 999\n 10 002\n \n \n 10 000\n 10 002\n \n \n 10 002\n 10 000\n \n \n \n \n\n\nk <- tt(data.frame(x = c(0.000123456789, 12.4356789)))\nformat_tt(k, digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1, num_fmt = \"decimal\", num_zero = TRUE) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.4\n 99T\n \n \n Food: Halloumi\n 201.4\n 7.3B\n \n \n Food: Tofu\n 0.1\n 29M\n \n \n Food: Beans\n 0.0\n 94K\n \n \n \n \n\n\ny <- tt(data.frame(x = c(123456789.678, 12435.6789)))\nformat_tt(y, digits=3, num_mark_big=\" \")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 123 456 790\n \n \n 12 436\n \n \n \n \n\n\nx <- tt(data.frame(Text = c(\"_italicized text_\", \"__bold text__\")))\nformat_tt(x, markdown=TRUE)\n\n\n\n \n\n \n \n \n \n \n \n Text\n \n \n \n \n \n italicized text\n \n \n bold text\n \n \n \n \n\n\ntab <- data.frame(a = c(NA, 1, 2), b = c(3, NA, 5))\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\ndat <- data.frame(\n \"LaTeX\" = c(\"Dollars $\", \"Percent %\", \"Underscore _\"),\n \"HTML\" = c(\"<br>\", \"<sup>4</sup>\", \"<emph>blah</emph>\")\n)\ntt(dat) |> format_tt(escape = TRUE) \n\n\n\n \n\n \n \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>",
"crumbs": [
"Tutorial (PDF)",
"Functions",
@@ -88,7 +88,7 @@
"href": "man/format_tt.html#format-columns-of-a-data-frame",
"title": "tinytable",
"section": "",
- "text": "This function formats the columns of a data frame based on the column type (logical, date, numeric). It allows various formatting options like significant digits, decimal points, and scientific notation. It also includes custom formatting for date and boolean values. If this function is applied several times to the same cell, the last transformation is retained and the previous calls are ignored, except for the escape argument which can be applied to previously transformed data.\n\n\n\nformat_tt(\n x,\n i = NULL,\n j = NULL,\n digits = get_option(\"tinytable_format_digits\", default = NULL),\n num_fmt = get_option(\"tinytable_format_num_fmt\", default = \"significant\"),\n num_zero = get_option(\"tinytable_format_num_zero\", default = FALSE),\n num_suffix = get_option(\"tinytable_format_num_suffix\", default = FALSE),\n num_mark_big = get_option(\"tinytable_format_num_mark_big\", default = \"\"),\n num_mark_dec = get_option(\"tinytable_format_num_mark_dec\", default =\n getOption(\"OutDec\", default = \".\")),\n date = get_option(\"tinytable_format_date\", default = \"%Y-%m-%d\"),\n bool = get_option(\"tinytable_format_bool\", default = function(column)\n tools::toTitleCase(tolower(column))),\n math = get_option(\"tinytable_format_math\", default = FALSE),\n other = get_option(\"tinytable_format_other\", default = as.character),\n replace = get_option(\"tinytable_format_replace\", default = TRUE),\n escape = get_option(\"tinytable_format_escape\", default = FALSE),\n markdown = get_option(\"tinytable_format_markdown\", default = FALSE),\n quarto = get_option(\"tinytable_format_quarto\", default = FALSE),\n fn = get_option(\"tinytable_format_fn\", default = NULL),\n sprintf = get_option(\"tinytable_format_sprintf\", default = NULL),\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA data frame or a vector to be formatted.\n\n\n\n\ni\n\n\nRow indices where the formatting should be applied.\n\n\n\n\nj\n\n\nColumn indices where the styling should be applied. Can be:\n\n\nInteger vectors indicating column positions.\n\n\nCharacter vector indicating column names.\n\n\nA single string specifying a Perl-style regular expression used to match column names.\n\n\n\n\n\n\ndigits\n\n\nNumber of significant digits or decimal places.\n\n\n\n\nnum_fmt\n\n\nThe format for numeric values; one of ‘significant’, ‘significant_cell’, ‘decimal’, or ‘scientific’.\n\n\n\n\nnum_zero\n\n\nLogical; if TRUE, trailing zeros are kept in \"decimal\" format (but not in \"significant\" format).\n\n\n\n\nnum_suffix\n\n\nLogical; if TRUE display short numbers with digits significant digits and K (thousands), M (millions), B (billions), or T (trillions) suffixes.\n\n\n\n\nnum_mark_big\n\n\nCharacter to use as a thousands separator.\n\n\n\n\nnum_mark_dec\n\n\nDecimal mark character. Default is the global option ‘OutDec’.\n\n\n\n\ndate\n\n\nA string passed to the format() function, such as \"%Y-%m-%d\". See the \"Details\" section in ?strptime\n\n\n\n\nbool\n\n\nA function to format logical columns. Defaults to title case.\n\n\n\n\nmath\n\n\nLogical. If TRUE, wrap cell values in math mode $..$. This is useful for LaTeX output or with HTML MathJax options(tinytable_html_mathjax=TRUE).\n\n\n\n\nother\n\n\nA function to format columns of other types. Defaults to as.character().\n\n\n\n\nreplace\n\n\nLogical, String or Named list of vectors\n\n\nTRUE: Replace NA by an empty string.\n\n\nFALSE: Print NA as the string \"NA\".\n\n\nString: Replace NA entries by the user-supplied string.\n\n\nNamed list: Replace matching elements of the vectors in the list by theirs names. Example:\n\n\nlist(“-” = c(NA, NaN), “Tiny” = -Inf, “Massive” = Inf)\n\n\n\n\n\n\n\n\nescape\n\n\nLogical or \"latex\" or \"html\". If TRUE, escape special characters to display them as text in the format of the output of a tt() table.\n\n\nIf i and j are both NULL, escape all cells, column names, caption, notes, and spanning labels created by group_tt().\n\n\n\n\n\n\nmarkdown\n\n\nLogical; if TRUE, render markdown syntax in cells. Ex: italicized text is properly italicized in HTML and LaTeX.\n\n\n\n\nquarto\n\n\nLogical. Enable Quarto data processing and wrap cell content in a data-qmd span (HTML) or macro (LaTeX). See warnings in the Global Options section below.\n\n\n\n\nfn\n\n\nFunction for custom formatting. Accepts a vector and returns a character vector of the same length.\n\n\n\n\nsprintf\n\n\nString passed to the ?sprintf function to format numbers or interpolate strings with a user-defined pattern (similar to the glue package, but using Base R).\n\n\n\n\n…\n\n\nAdditional arguments are ignored.\n\n\n\n\n\n\nA data frame with formatted columns.\n\n\n\n\n\n\n\noptions(“tinytable_quarto_figure” = FALSE): Typst only. Normally, it is best to allow Quarto to define the figure environment, so the default behavior is to not include one.\n\n\n\nThe format_tt(quarto=TRUE) argument activates Quarto data processing for specific cells. This funcationality comes with a few warnings:\n\n\nCurrently, Quarto provides a LaTeX macro, but it does not appear to do anything with it. References and markdown codes may not be processed as expected in LaTeX.\n\n\nQuarto data processing can enter in conflict with tinytable styling or formatting options. See below for how to disable it.\n\n\noptions(tinytable_quarto_disable_processing = TRUE)\nDisable Quarto processing of cell content. Setting this global option to FALSE may lead to conflicts with some tinytable features, but it also allows use of markdown and Quarto-specific code in table cells, such as cross-references.\n\nx <- data.frame(Math = \"x^2^\", Citation = \"@Lovelace1842\")\nfn <- function(z) sprintf(\"<span data-qmd='%s'></span>\", z)\ntt(x) |> format_tt(i = 1, fn = fn)\n\n\nSee this link for more details: https://quarto.org/docs/authoring/tables.html#disabling-quarto-table-processing\n\n\n\noptions(tinytable_html_mathjax = TRUE): insert MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\noptions(tinytable_html_portable = TRUE): plot_tt() inserts base 64 encoded images directly in the HTML file rather than use external links.\n\n\n\n\n\noptions(tinytable_pdf_clean = TRUE) deletes temporary and log files.\n\n\noptions(tinytable_pdf_engine = “xelatex”): \"xelatex\", \"pdflatex\", \"lualatex\"\n\n\n\n\n\n\nlibrary(\"tinytable\")\n\ndat <- data.frame(\n a = rnorm(3, mean = 10000),\n b = rnorm(3, 10000))\ntab <- tt(dat)\nformat_tt(tab,\n digits = 2,\n num_mark_dec = \",\",\n num_mark_big = \" \")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 10 000\n 9 999\n \n \n 9 999\n 10 001\n \n \n 10 002\n 9 999\n \n \n \n \n\n\nk <- tt(data.frame(x = c(0.000123456789, 12.4356789)))\nformat_tt(k, digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1, num_fmt = \"decimal\", num_zero = TRUE) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.4\n 99T\n \n \n Food: Halloumi\n 201.4\n 7.3B\n \n \n Food: Tofu\n 0.1\n 29M\n \n \n Food: Beans\n 0.0\n 94K\n \n \n \n \n\n\ny <- tt(data.frame(x = c(123456789.678, 12435.6789)))\nformat_tt(y, digits=3, num_mark_big=\" \")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 123 456 790\n \n \n 12 436\n \n \n \n \n\n\nx <- tt(data.frame(Text = c(\"_italicized text_\", \"__bold text__\")))\nformat_tt(x, markdown=TRUE)\n\n\n\n \n\n \n \n \n \n \n \n Text\n \n \n \n \n \n italicized text\n \n \n bold text\n \n \n \n \n\n\ntab <- data.frame(a = c(NA, 1, 2), b = c(3, NA, 5))\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\ndat <- data.frame(\n \"LaTeX\" = c(\"Dollars $\", \"Percent %\", \"Underscore _\"),\n \"HTML\" = c(\"<br>\", \"<sup>4</sup>\", \"<emph>blah</emph>\")\n)\ntt(dat) |> format_tt(escape = TRUE) \n\n\n\n \n\n \n \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>",
+ "text": "This function formats the columns of a data frame based on the column type (logical, date, numeric). It allows various formatting options like significant digits, decimal points, and scientific notation. It also includes custom formatting for date and boolean values. If this function is applied several times to the same cell, the last transformation is retained and the previous calls are ignored, except for the escape argument which can be applied to previously transformed data.\n\n\n\nformat_tt(\n x,\n i = NULL,\n j = NULL,\n digits = get_option(\"tinytable_format_digits\", default = NULL),\n num_fmt = get_option(\"tinytable_format_num_fmt\", default = \"significant\"),\n num_zero = get_option(\"tinytable_format_num_zero\", default = FALSE),\n num_suffix = get_option(\"tinytable_format_num_suffix\", default = FALSE),\n num_mark_big = get_option(\"tinytable_format_num_mark_big\", default = \"\"),\n num_mark_dec = get_option(\"tinytable_format_num_mark_dec\", default =\n getOption(\"OutDec\", default = \".\")),\n date = get_option(\"tinytable_format_date\", default = \"%Y-%m-%d\"),\n bool = get_option(\"tinytable_format_bool\", default = function(column)\n tools::toTitleCase(tolower(column))),\n math = get_option(\"tinytable_format_math\", default = FALSE),\n other = get_option(\"tinytable_format_other\", default = as.character),\n replace = get_option(\"tinytable_format_replace\", default = TRUE),\n escape = get_option(\"tinytable_format_escape\", default = FALSE),\n markdown = get_option(\"tinytable_format_markdown\", default = FALSE),\n quarto = get_option(\"tinytable_format_quarto\", default = FALSE),\n fn = get_option(\"tinytable_format_fn\", default = NULL),\n sprintf = get_option(\"tinytable_format_sprintf\", default = NULL),\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA data frame or a vector to be formatted.\n\n\n\n\ni\n\n\nRow indices where the formatting should be applied.\n\n\n\n\nj\n\n\nColumn indices where the styling should be applied. Can be:\n\n\nInteger vectors indicating column positions.\n\n\nCharacter vector indicating column names.\n\n\nA single string specifying a Perl-style regular expression used to match column names.\n\n\n\n\n\n\ndigits\n\n\nNumber of significant digits or decimal places.\n\n\n\n\nnum_fmt\n\n\nThe format for numeric values; one of ‘significant’, ‘significant_cell’, ‘decimal’, or ‘scientific’.\n\n\n\n\nnum_zero\n\n\nLogical; if TRUE, trailing zeros are kept in \"decimal\" format (but not in \"significant\" format).\n\n\n\n\nnum_suffix\n\n\nLogical; if TRUE display short numbers with digits significant digits and K (thousands), M (millions), B (billions), or T (trillions) suffixes.\n\n\n\n\nnum_mark_big\n\n\nCharacter to use as a thousands separator.\n\n\n\n\nnum_mark_dec\n\n\nDecimal mark character. Default is the global option ‘OutDec’.\n\n\n\n\ndate\n\n\nA string passed to the format() function, such as \"%Y-%m-%d\". See the \"Details\" section in ?strptime\n\n\n\n\nbool\n\n\nA function to format logical columns. Defaults to title case.\n\n\n\n\nmath\n\n\nLogical. If TRUE, wrap cell values in math mode $..$. This is useful for LaTeX output or with HTML MathJax options(tinytable_html_mathjax=TRUE).\n\n\n\n\nother\n\n\nA function to format columns of other types. Defaults to as.character().\n\n\n\n\nreplace\n\n\nLogical, String or Named list of vectors\n\n\nTRUE: Replace NA by an empty string.\n\n\nFALSE: Print NA as the string \"NA\".\n\n\nString: Replace NA entries by the user-supplied string.\n\n\nNamed list: Replace matching elements of the vectors in the list by theirs names. Example:\n\n\nlist(“-” = c(NA, NaN), “Tiny” = -Inf, “Massive” = Inf)\n\n\n\n\n\n\n\n\nescape\n\n\nLogical or \"latex\" or \"html\". If TRUE, escape special characters to display them as text in the format of the output of a tt() table.\n\n\nIf i and j are both NULL, escape all cells, column names, caption, notes, and spanning labels created by group_tt().\n\n\n\n\n\n\nmarkdown\n\n\nLogical; if TRUE, render markdown syntax in cells. Ex: italicized text is properly italicized in HTML and LaTeX.\n\n\n\n\nquarto\n\n\nLogical. Enable Quarto data processing and wrap cell content in a data-qmd span (HTML) or macro (LaTeX). See warnings in the Global Options section below.\n\n\n\n\nfn\n\n\nFunction for custom formatting. Accepts a vector and returns a character vector of the same length.\n\n\n\n\nsprintf\n\n\nString passed to the ?sprintf function to format numbers or interpolate strings with a user-defined pattern (similar to the glue package, but using Base R).\n\n\n\n\n…\n\n\nAdditional arguments are ignored.\n\n\n\n\n\n\nA data frame with formatted columns.\n\n\n\n\n\n\n\noptions(“tinytable_quarto_figure” = FALSE): Typst only. Normally, it is best to allow Quarto to define the figure environment, so the default behavior is to not include one.\n\n\n\nThe format_tt(quarto=TRUE) argument activates Quarto data processing for specific cells. This funcationality comes with a few warnings:\n\n\nCurrently, Quarto provides a LaTeX macro, but it does not appear to do anything with it. References and markdown codes may not be processed as expected in LaTeX.\n\n\nQuarto data processing can enter in conflict with tinytable styling or formatting options. See below for how to disable it.\n\n\noptions(tinytable_quarto_disable_processing = TRUE)\nDisable Quarto processing of cell content. Setting this global option to FALSE may lead to conflicts with some tinytable features, but it also allows use of markdown and Quarto-specific code in table cells, such as cross-references.\n\nx <- data.frame(Math = \"x^2^\", Citation = \"@Lovelace1842\")\nfn <- function(z) sprintf(\"<span data-qmd='%s'></span>\", z)\ntt(x) |> format_tt(i = 1, fn = fn)\n\n\nSee this link for more details: https://quarto.org/docs/authoring/tables.html#disabling-quarto-table-processing\n\n\n\noptions(tinytable_html_mathjax = TRUE): insert MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\noptions(tinytable_html_portable = TRUE): plot_tt() inserts base 64 encoded images directly in the HTML file rather than use external links.\n\n\n\n\n\noptions(tinytable_pdf_clean = TRUE) deletes temporary and log files.\n\n\noptions(tinytable_pdf_engine = “xelatex”): \"xelatex\", \"pdflatex\", \"lualatex\"\n\n\n\n\n\n\nlibrary(\"tinytable\")\n\ndat <- data.frame(\n a = rnorm(3, mean = 10000),\n b = rnorm(3, 10000))\ntab <- tt(dat)\nformat_tt(tab,\n digits = 2,\n num_mark_dec = \",\",\n num_mark_big = \" \")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 9 999\n 10 002\n \n \n 10 000\n 10 002\n \n \n 10 002\n 10 000\n \n \n \n \n\n\nk <- tt(data.frame(x = c(0.000123456789, 12.4356789)))\nformat_tt(k, digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1, num_fmt = \"decimal\", num_zero = TRUE) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.4\n 99T\n \n \n Food: Halloumi\n 201.4\n 7.3B\n \n \n Food: Tofu\n 0.1\n 29M\n \n \n Food: Beans\n 0.0\n 94K\n \n \n \n \n\n\ny <- tt(data.frame(x = c(123456789.678, 12435.6789)))\nformat_tt(y, digits=3, num_mark_big=\" \")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 123 456 790\n \n \n 12 436\n \n \n \n \n\n\nx <- tt(data.frame(Text = c(\"_italicized text_\", \"__bold text__\")))\nformat_tt(x, markdown=TRUE)\n\n\n\n \n\n \n \n \n \n \n \n Text\n \n \n \n \n \n italicized text\n \n \n bold text\n \n \n \n \n\n\ntab <- data.frame(a = c(NA, 1, 2), b = c(3, NA, 5))\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\ndat <- data.frame(\n \"LaTeX\" = c(\"Dollars $\", \"Percent %\", \"Underscore _\"),\n \"HTML\" = c(\"<br>\", \"<sup>4</sup>\", \"<emph>blah</emph>\")\n)\ntt(dat) |> format_tt(escape = TRUE) \n\n\n\n \n\n \n \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>",
"crumbs": [
"Tutorial (PDF)",
"Functions",
@@ -639,7 +639,7 @@
"href": "vignettes/format.html",
"title": "Formatting",
"section": "",
- "text": "library(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\nx <- mtcars[1:4, 1:5]\n\n\n\nThe tt() function is minimalist; it’s inteded purpose is simply to draw nice tables. Users who want to format numbers, dates, strings, and other variables in different ways should process their data before supplying it to the tt() table-drawing function. To do so, we can use the format_tt() function supplied by the tinytable.\nIn a very simple case—such as printing 2 significant digits of all numeric variables—we can use the digits argument of tt():\n\ndat <- data.frame(\n w = c(143002.2092, 201399.181, 100188.3883),\n x = c(1.43402, 201.399, 0.134588),\n y = as.Date(sample(1:1000, 3), origin = \"1970-01-01\"),\n z = c(TRUE, TRUE, FALSE))\n\ntt(dat, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143002\n 1.43\n 1971-03-08\n True \n \n \n 201399\n 201.4 \n 1970-08-16\n True \n \n \n 100188\n 0.13\n 1971-09-16\n False\n \n \n \n \n\n\n\nWe can get more fine-grained control over formatting by calling format_tt() after tt(), optionally by specifying the columns to format with j:\n\ntt(dat) |> \n format_tt(\n j = 2:4,\n digits = 1,\n date = \"%B %d %Y\") |>\n format_tt(\n j = 1,\n digits = 2,\n num_mark_big = \" \",\n num_mark_dec = \",\",\n num_fmt = \"decimal\")\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143 002,21\n 1.4\n March 08 1971\n True\n \n \n 201 399,18\n 201.4\n August 16 1970\n True\n \n \n 100 188,39\n 0.1\n September 16 1971\n False\n \n \n \n \n\n\n\nWe can use a regular expression in j to select columns, and the ?sprintf function to format strings, numbers, and to do string interpolation (similar to the glue package, but using Base R):\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.432\n 99T\n \n \n Food: Halloumi\n 201.399\n 7.3B\n \n \n Food: Tofu\n 0.146\n 29M\n \n \n Food: Beans\n 0.003\n 94K\n \n \n \n \n\n\n\nFinally, if you like the format_tt() interface, you can use it directly with numbers, vectors, or data frames:\n\nformat_tt(pi, digits = 1)\n\n[1] \"3\"\n\nformat_tt(dat, digits = 1, num_suffix = TRUE)\n\n a b c\n1 Burger 1 99T\n2 Halloumi 201 7B\n3 Tofu 0.1 29M\n4 Beans 0.003 94K\n\n\n\n\n\nBy default, format_tt() formats numbers to ensure that the smallest value in a vector (column) has at least a certain number of significant digits. For example,\n\nk <- data.frame(x = c(0.000123456789, 12.4356789))\ntt(k, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12.43568\n \n \n \n \n\n\n\nWe can alter this behavior to ensure to round significant digits on a per-cell basis, using the num_fmt argument in format_tt():\n\ntt(k) |> format_tt(digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\n\nThe numeric formatting options in format_tt() can also be controlled using global options:\n\noptions(\"tinytable_tt_digits\" = 2)\noptions(\"tinytable_format_num_fmt\" = \"significant_cell\")\ntt(k)\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12 \n \n \n \n \n\n\n\n\n\n\nTo insert LaTeX-style mathematical expressions in a tinytable, we enclose the expression in dollar signs: $...$. Note that you must double backslashes in mathematical expressions in R strings.\nIn LaTeX, expression enclosed between $$ will automatically rendered as a mathematical expression.\nIn HTML, users must first load the MathJax JavaScript library to render math. This can be done in two ways. First, one can use a global option. This will insert MathJax scripts alongside every table, which is convenient, but could enter in conflict with other scripts if the user (or notebook) has already inserted MathJax code:\noptions(tinytable_html_mathjax = TRUE)\nAlternatively, users can load MathJax explicitly in their HTML file. In a Quarto notebook, this can be done by using a code chunk like this:\n```{=html}\n<script id=\"MathJax-script\" async src=\"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js\"></script>\n<script>\nMathJax = {\n tex: {\n inlineMath: [['$', '$'], ['\\\\(', '\\\\)']]\n },\n svg: {\n fontCache: 'global'\n }\n};\n</script>\n```\nThen, we can do:\n\ndat <- data.frame(Math = c(\n \"$x^2 + y^2 = z^2$\",\n \"$\\\\frac{1}{2}$\"\n))\ntt(dat) |> style_tt(j = 1, align = \"c\")\n\n\n\n \n\n \n \n \n \n \n \n Math\n \n \n \n \n \n $x^2 + y^2 = z^2$\n \n \n $\\frac{1}{2}$ \n \n \n \n \n\n\n\nTo avoid inserting $...$ in every cell manually, we can use the math argument of format_tt():\n\noptions(tinytable_html_mathjax = TRUE)\n\ndat <- data.frame(\"y^2 = e^x\" = c(-2, -pi), check.names = FALSE)\n\ntt(dat, digits = 3) |> format_tt(math = TRUE)\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n $y^2 = e^x$\n \n \n \n \n \n $-2 $\n \n \n $-3.14$\n \n \n \n \n\n\n\n\n\n\nMissing values can be replaced by a custom string using the replace argument (default \"\"):\n\ntab <- data.frame(a = c(NA, 1, 2), b = c(3, NA, 5))\n\ntt(tab)\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n NA\n 3\n \n \n 1\n NA\n \n \n 2\n 5\n \n \n \n \n\n\ntt(tab) |> format_tt()\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n \n 3\n \n \n 1\n \n \n \n 2\n 5\n \n \n \n \n\n\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\n\nWe can also specify multiple value replacements at once using a named list of vectors:\n\ntmp <- data.frame(x = 1:5, y = c(pi, NA, NaN, -Inf, Inf))\ndict <- list(\"-\" = c(NA, NaN), \"-∞\" = -Inf, \"∞\" = Inf)\ntt(tmp) |> format_tt(replace = dict, digits = 2)\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n x\n y\n \n \n \n \n \n 1\n 3.1\n \n \n 2\n -\n \n \n 3\n -\n \n \n 4\n -∞\n \n \n 5\n ∞\n \n \n \n \n\n\n\n\n\n\nLaTeX and HTML use special characters to indicate strings which should be interpreted rather than displayed as text. For example, including underscores or dollar signs in LaTeX can cause compilation errors in some documents. To display those special characters, we need to substitute or escape them with backslashes, depending on the output format. The escape argument of format_tt() can be used to do this automatically:\n\ndat <- data.frame(\n \"LaTeX\" = c(\"Dollars $\", \"Percent %\", \"Underscore _\"),\n \"HTML\" = c(\"<br>\", \"<sup>4</sup>\", \"<emph>blah</emph>\")\n)\n\ntt(dat) |> format_tt(escape = TRUE)\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>\n \n \n \n \n\n\n\nWhen applied to a tt() table, format_tt() will determine the type of escaping to do automatically. When applied to a string or vector, we must specify the type of escaping to apply:\n\nformat_tt(\"_ Dollars $\", escape = \"latex\")\n\n[1] \"\\\\_ Dollars \\\\$\"\n\n\n\n\n\nMarkdown can be rendered in cells by using the markdown argument of the format_tt() function (note: this requires installing the markdown as an optional dependency).\n\ndat <- data.frame( markdown = c(\n \"This is _italic_ text.\",\n \"This sentence ends with a superscript.^2^\")\n)\n\ntt(dat) |>\n format_tt(j = 1, markdown = TRUE) |>\n style_tt(j = 1, align = \"c\")\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n markdown\n \n \n \n \n \n This is italic text.\n \n \n This sentence ends with a superscript.2\n \n \n \n \n\n\n\nMarkdown syntax can be particularly useful when formatting URLs in a table:\n\ndat <- data.frame(\n `Package (link)` = c(\n \"[`marginaleffects`](https://www.marginaleffects.com/)\",\n \"[`modelsummary`](https://www.modelsummary.com/)\",\n \"[`tinytable`](https://vincentarelbundock.github.io/tinytable/)\",\n \"[`countrycode`](https://vincentarelbundock.github.io/countrycode/)\",\n \"[`WDI`](https://vincentarelbundock.github.io/WDI/)\",\n \"[`softbib`](https://vincentarelbundock.github.io/softbib/)\",\n \"[`tinysnapshot`](https://vincentarelbundock.github.io/tinysnapshot/)\",\n \"[`altdoc`](https://etiennebacher.github.io/altdoc/)\",\n \"[`tinyplot`](https://grantmcdermott.com/tinyplot/)\",\n \"[`parameters`](https://easystats.github.io/parameters/)\",\n \"[`insight`](https://easystats.github.io/insight/)\"\n ),\n Purpose = c(\n \"Interpreting statistical models\",\n \"Data and model summaries\",\n \"Draw beautiful tables easily\",\n \"Convert country codes and names\",\n \"Download data from the World Bank\",\n \"Software bibliographies in R\",\n \"Snapshots for unit tests using `tinytest`\",\n \"Create documentation website for R packages\",\n \"Extension of base R plot functions\",\n \"Extract from model objects\",\n \"Extract information from model objects\"\n ),\n check.names = FALSE\n)\n\ntt(dat) |> format_tt(j = 1, markdown = TRUE)\n\n\n\n \n \n \n \n\n \n\n \n \n Vincent sometimes contributes to these R packages.\n \n \n \n Package (link)\n Purpose\n \n \n \n \n \n marginaleffects\n Interpreting statistical models \n \n \n modelsummary\n Data and model summaries \n \n \n tinytable\n Draw beautiful tables easily \n \n \n countrycode\n Convert country codes and names \n \n \n WDI\n Download data from the World Bank \n \n \n softbib\n Software bibliographies in R \n \n \n tinysnapshot\n Snapshots for unit tests using `tinytest` \n \n \n altdoc\n Create documentation website for R packages\n \n \n tinyplot\n Extension of base R plot functions \n \n \n parameters\n Extract from model objects \n \n \n insight\n Extract information from model objects \n \n \n \n \n\n\n\n\n\n\nOn top of the built-in features of format_tt, a custom formatting function can be specified via the fn argument. The fn argument takes a function that accepts a single vector and returns a string (or something that coerces to a string like a number).\n\ntt(x) |> \n format_tt(j = \"mpg\", fn = function(x) paste0(x, \" mpg\")) |>\n format_tt(j = \"drat\", fn = \\(x) signif(x, 2))\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21 mpg\n 6\n 160\n 110\n 3.9\n \n \n 21 mpg\n 6\n 160\n 110\n 3.9\n \n \n 22.8 mpg\n 4\n 108\n 93\n 3.8\n \n \n 21.4 mpg\n 6\n 258\n 110\n 3.1\n \n \n \n \n\n\n\nFor example, the scales package which is used internally by ggplot2 provides a bunch of useful tools for formatting (e.g. dates, numbers, percents, logs, currencies, etc.). The label_*() functions can be passed to the fn argument.\nNote that we call format_tt(escape = TRUE) at the end of the pipeline because the column names and cells include characters that need to be escaped in LaTeX: _, %, and $. This last call is superfluous in HTML.\n\nthumbdrives <- data.frame(\n date_lookup = as.Date(c(\"2024-01-15\", \"2024-01-18\", \"2024-01-14\", \"2024-01-16\")),\n price = c(18.49, 19.99, 24.99, 24.99),\n price_rank = c(1, 2, 3, 3),\n memory = c(16e9, 12e9, 10e9, 8e9),\n speed_benchmark = c(0.6, 0.73, 0.82, 0.99)\n)\n\ntt(thumbdrives) |>\n format_tt(j = 1, fn = scales::label_date(\"%e %b\", locale = \"fr\")) |>\n format_tt(j = 2, fn = scales::label_currency()) |>\n format_tt(j = 3, fn = scales::label_ordinal()) |> \n format_tt(j = 4, fn = scales::label_bytes()) |> \n format_tt(j = 5, fn = scales::label_percent()) |>\n format_tt(escape = TRUE)\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n date_lookup\n price\n price_rank\n memory\n speed_benchmark\n \n \n \n \n \n 2024-01-15\n $18.49\n 1st\n 16 GB\n 60%\n \n \n 2024-01-18\n $19.99\n 2nd\n 12 GB\n 73%\n \n \n 2024-01-14\n $24.99\n 3rd\n 10 GB\n 82%\n \n \n 2024-01-16\n $24.99\n 3rd\n 8 GB\n 99%\n \n \n \n \n\n\n\n\n\n\nQuarto automatically applies some data processing to the content of the tables it renders. By default, tinytable disables this processing, because it can enter in conflict with styling and formatting features of the package.\nTo enable Quarto data processing, we can use the quarto argument of the format_tt() function. This argument allows users to mark certain cells explicitly for processing by Quarto, by wrapping them in a special “span” called “data-qmd”, supported by Quarto:\n\nk <- data.frame(Thing = \"qwerty\", Citation = \"@Lovelace1842\")\n\ntt(k) |> format_tt(quarto = TRUE)\n\n\n\n \n \n \n \n\n \n\n \n \n \n\n\n\nThing\nCitation\n\n\n\n\nqwerty\nLovelace (1842)\n\n\n\n\n \n\n\n\nSome users may want to apply Quarto data processing to all tables. This can be done with themes:\n\ntheme_quarto <- function(x) format_tt(x, quarto = TRUE)\noptions(tinytable_tt_theme = theme_quarto)\n\ntt(k)\n\n\n\n \n \n \n \n\n \n\n \n \n \n\n\n\nThing\nCitation\n\n\n\n\nqwerty\nLovelace (1842)\n\n\n\n\n \n\n\n\nBack to normal:\n\noptions(tinytable_tt_theme = NULL)\n\nAlternatively, users can set a global option to process all tables in Quarto, but they will then have to mark each cell with special content using format_tt(quarto):\n\noptions(tinytable_quarto_disable_processing = FALSE)\n\ntt(x)\n\n\n\n \n \n \n \n\n \n\n \n \n \n\n\n\nmpg\ncyl\ndisp\nhp\ndrat\n\n\n\n\n21.0\n6\n160\n110\n3.90\n\n\n21.0\n6\n160\n110\n3.90\n\n\n22.8\n4\n108\n93\n3.85\n\n\n21.4\n6\n258\n110\n3.08\n\n\n\n\n \n\n\n\nNotice that Quarto is now processing the table, so we lose the default tinytable theme and get the default striped Quarto look.\nBack to normal:\n\noptions(tinytable_quarto_disable_processing = TRUE)",
+ "text": "library(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\nx <- mtcars[1:4, 1:5]\n\n\n\nThe tt() function is minimalist; it’s inteded purpose is simply to draw nice tables. Users who want to format numbers, dates, strings, and other variables in different ways should process their data before supplying it to the tt() table-drawing function. To do so, we can use the format_tt() function supplied by the tinytable.\nIn a very simple case—such as printing 2 significant digits of all numeric variables—we can use the digits argument of tt():\n\ndat <- data.frame(\n w = c(143002.2092, 201399.181, 100188.3883),\n x = c(1.43402, 201.399, 0.134588),\n y = as.Date(sample(1:1000, 3), origin = \"1970-01-01\"),\n z = c(TRUE, TRUE, FALSE))\n\ntt(dat, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143002\n 1.43\n 1971-10-17\n True \n \n \n 201399\n 201.4 \n 1970-12-24\n True \n \n \n 100188\n 0.13\n 1971-12-13\n False\n \n \n \n \n\n\n\nWe can get more fine-grained control over formatting by calling format_tt() after tt(), optionally by specifying the columns to format with j:\n\ntt(dat) |> \n format_tt(\n j = 2:4,\n digits = 1,\n date = \"%B %d %Y\") |>\n format_tt(\n j = 1,\n digits = 2,\n num_mark_big = \" \",\n num_mark_dec = \",\",\n num_fmt = \"decimal\")\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143 002,21\n 1.4\n October 17 1971\n True\n \n \n 201 399,18\n 201.4\n December 24 1970\n True\n \n \n 100 188,39\n 0.1\n December 13 1971\n False\n \n \n \n \n\n\n\nWe can use a regular expression in j to select columns, and the ?sprintf function to format strings, numbers, and to do string interpolation (similar to the glue package, but using Base R):\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.432\n 99T\n \n \n Food: Halloumi\n 201.399\n 7.3B\n \n \n Food: Tofu\n 0.146\n 29M\n \n \n Food: Beans\n 0.003\n 94K\n \n \n \n \n\n\n\nFinally, if you like the format_tt() interface, you can use it directly with numbers, vectors, or data frames:\n\nformat_tt(pi, digits = 1)\n\n[1] \"3\"\n\nformat_tt(dat, digits = 1, num_suffix = TRUE)\n\n a b c\n1 Burger 1 99T\n2 Halloumi 201 7B\n3 Tofu 0.1 29M\n4 Beans 0.003 94K\n\n\n\n\n\nBy default, format_tt() formats numbers to ensure that the smallest value in a vector (column) has at least a certain number of significant digits. For example,\n\nk <- data.frame(x = c(0.000123456789, 12.4356789))\ntt(k, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12.43568\n \n \n \n \n\n\n\nWe can alter this behavior to ensure to round significant digits on a per-cell basis, using the num_fmt argument in format_tt():\n\ntt(k) |> format_tt(digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\n\nThe numeric formatting options in format_tt() can also be controlled using global options:\n\noptions(\"tinytable_tt_digits\" = 2)\noptions(\"tinytable_format_num_fmt\" = \"significant_cell\")\ntt(k)\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12 \n \n \n \n \n\n\n\n\n\n\nTo insert LaTeX-style mathematical expressions in a tinytable, we enclose the expression in dollar signs: $...$. Note that you must double backslashes in mathematical expressions in R strings.\nIn LaTeX, expression enclosed between $$ will automatically rendered as a mathematical expression.\nIn HTML, users must first load the MathJax JavaScript library to render math. This can be done in two ways. First, one can use a global option. This will insert MathJax scripts alongside every table, which is convenient, but could enter in conflict with other scripts if the user (or notebook) has already inserted MathJax code:\noptions(tinytable_html_mathjax = TRUE)\nAlternatively, users can load MathJax explicitly in their HTML file. In a Quarto notebook, this can be done by using a code chunk like this:\n```{=html}\n<script id=\"MathJax-script\" async src=\"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js\"></script>\n<script>\nMathJax = {\n tex: {\n inlineMath: [['$', '$'], ['\\\\(', '\\\\)']]\n },\n svg: {\n fontCache: 'global'\n }\n};\n</script>\n```\nThen, we can do:\n\ndat <- data.frame(Math = c(\n \"$x^2 + y^2 = z^2$\",\n \"$\\\\frac{1}{2}$\"\n))\ntt(dat) |> style_tt(j = 1, align = \"c\")\n\n\n\n \n\n \n \n \n \n \n \n Math\n \n \n \n \n \n $x^2 + y^2 = z^2$\n \n \n $\\frac{1}{2}$ \n \n \n \n \n\n\n\nTo avoid inserting $...$ in every cell manually, we can use the math argument of format_tt():\n\noptions(tinytable_html_mathjax = TRUE)\n\ndat <- data.frame(\"y^2 = e^x\" = c(-2, -pi), check.names = FALSE)\n\ntt(dat, digits = 3) |> format_tt(math = TRUE)\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n $y^2 = e^x$\n \n \n \n \n \n $-2 $\n \n \n $-3.14$\n \n \n \n \n\n\n\n\n\n\nMissing values can be replaced by a custom string using the replace argument (default \"\"):\n\ntab <- data.frame(a = c(NA, 1, 2), b = c(3, NA, 5))\n\ntt(tab)\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n NA\n 3\n \n \n 1\n NA\n \n \n 2\n 5\n \n \n \n \n\n\ntt(tab) |> format_tt()\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n \n 3\n \n \n 1\n \n \n \n 2\n 5\n \n \n \n \n\n\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\n\nWe can also specify multiple value replacements at once using a named list of vectors:\n\ntmp <- data.frame(x = 1:5, y = c(pi, NA, NaN, -Inf, Inf))\ndict <- list(\"-\" = c(NA, NaN), \"-∞\" = -Inf, \"∞\" = Inf)\ntt(tmp) |> format_tt(replace = dict, digits = 2)\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n x\n y\n \n \n \n \n \n 1\n 3.1\n \n \n 2\n -\n \n \n 3\n -\n \n \n 4\n -∞\n \n \n 5\n ∞\n \n \n \n \n\n\n\n\n\n\nLaTeX and HTML use special characters to indicate strings which should be interpreted rather than displayed as text. For example, including underscores or dollar signs in LaTeX can cause compilation errors in some documents. To display those special characters, we need to substitute or escape them with backslashes, depending on the output format. The escape argument of format_tt() can be used to do this automatically:\n\ndat <- data.frame(\n \"LaTeX\" = c(\"Dollars $\", \"Percent %\", \"Underscore _\"),\n \"HTML\" = c(\"<br>\", \"<sup>4</sup>\", \"<emph>blah</emph>\")\n)\n\ntt(dat) |> format_tt(escape = TRUE)\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>\n \n \n \n \n\n\n\nWhen applied to a tt() table, format_tt() will determine the type of escaping to do automatically. When applied to a string or vector, we must specify the type of escaping to apply:\n\nformat_tt(\"_ Dollars $\", escape = \"latex\")\n\n[1] \"\\\\_ Dollars \\\\$\"\n\n\n\n\n\nMarkdown can be rendered in cells by using the markdown argument of the format_tt() function (note: this requires installing the markdown as an optional dependency).\n\ndat <- data.frame( markdown = c(\n \"This is _italic_ text.\",\n \"This sentence ends with a superscript.^2^\")\n)\n\ntt(dat) |>\n format_tt(j = 1, markdown = TRUE) |>\n style_tt(j = 1, align = \"c\")\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n markdown\n \n \n \n \n \n This is italic text.\n \n \n This sentence ends with a superscript.2\n \n \n \n \n\n\n\nMarkdown syntax can be particularly useful when formatting URLs in a table:\n\ndat <- data.frame(\n `Package (link)` = c(\n \"[`marginaleffects`](https://www.marginaleffects.com/)\",\n \"[`modelsummary`](https://www.modelsummary.com/)\",\n \"[`tinytable`](https://vincentarelbundock.github.io/tinytable/)\",\n \"[`countrycode`](https://vincentarelbundock.github.io/countrycode/)\",\n \"[`WDI`](https://vincentarelbundock.github.io/WDI/)\",\n \"[`softbib`](https://vincentarelbundock.github.io/softbib/)\",\n \"[`tinysnapshot`](https://vincentarelbundock.github.io/tinysnapshot/)\",\n \"[`altdoc`](https://etiennebacher.github.io/altdoc/)\",\n \"[`tinyplot`](https://grantmcdermott.com/tinyplot/)\",\n \"[`parameters`](https://easystats.github.io/parameters/)\",\n \"[`insight`](https://easystats.github.io/insight/)\"\n ),\n Purpose = c(\n \"Interpreting statistical models\",\n \"Data and model summaries\",\n \"Draw beautiful tables easily\",\n \"Convert country codes and names\",\n \"Download data from the World Bank\",\n \"Software bibliographies in R\",\n \"Snapshots for unit tests using `tinytest`\",\n \"Create documentation website for R packages\",\n \"Extension of base R plot functions\",\n \"Extract from model objects\",\n \"Extract information from model objects\"\n ),\n check.names = FALSE\n)\n\ntt(dat) |> format_tt(j = 1, markdown = TRUE)\n\n\n\n \n \n \n \n\n \n\n \n \n Vincent sometimes contributes to these R packages.\n \n \n \n Package (link)\n Purpose\n \n \n \n \n \n marginaleffects\n Interpreting statistical models \n \n \n modelsummary\n Data and model summaries \n \n \n tinytable\n Draw beautiful tables easily \n \n \n countrycode\n Convert country codes and names \n \n \n WDI\n Download data from the World Bank \n \n \n softbib\n Software bibliographies in R \n \n \n tinysnapshot\n Snapshots for unit tests using `tinytest` \n \n \n altdoc\n Create documentation website for R packages\n \n \n tinyplot\n Extension of base R plot functions \n \n \n parameters\n Extract from model objects \n \n \n insight\n Extract information from model objects \n \n \n \n \n\n\n\n\n\n\nOn top of the built-in features of format_tt, a custom formatting function can be specified via the fn argument. The fn argument takes a function that accepts a single vector and returns a string (or something that coerces to a string like a number).\n\ntt(x) |> \n format_tt(j = \"mpg\", fn = function(x) paste0(x, \" mpg\")) |>\n format_tt(j = \"drat\", fn = \\(x) signif(x, 2))\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21 mpg\n 6\n 160\n 110\n 3.9\n \n \n 21 mpg\n 6\n 160\n 110\n 3.9\n \n \n 22.8 mpg\n 4\n 108\n 93\n 3.8\n \n \n 21.4 mpg\n 6\n 258\n 110\n 3.1\n \n \n \n \n\n\n\nFor example, the scales package which is used internally by ggplot2 provides a bunch of useful tools for formatting (e.g. dates, numbers, percents, logs, currencies, etc.). The label_*() functions can be passed to the fn argument.\nNote that we call format_tt(escape = TRUE) at the end of the pipeline because the column names and cells include characters that need to be escaped in LaTeX: _, %, and $. This last call is superfluous in HTML.\n\nthumbdrives <- data.frame(\n date_lookup = as.Date(c(\"2024-01-15\", \"2024-01-18\", \"2024-01-14\", \"2024-01-16\")),\n price = c(18.49, 19.99, 24.99, 24.99),\n price_rank = c(1, 2, 3, 3),\n memory = c(16e9, 12e9, 10e9, 8e9),\n speed_benchmark = c(0.6, 0.73, 0.82, 0.99)\n)\n\ntt(thumbdrives) |>\n format_tt(j = 1, fn = scales::label_date(\"%e %b\", locale = \"fr\")) |>\n format_tt(j = 2, fn = scales::label_currency()) |>\n format_tt(j = 3, fn = scales::label_ordinal()) |> \n format_tt(j = 4, fn = scales::label_bytes()) |> \n format_tt(j = 5, fn = scales::label_percent()) |>\n format_tt(escape = TRUE)\n\n\n\n \n \n \n \n\n \n\n \n \n \n \n \n \n date_lookup\n price\n price_rank\n memory\n speed_benchmark\n \n \n \n \n \n 2024-01-15\n $18.49\n 1st\n 16 GB\n 60%\n \n \n 2024-01-18\n $19.99\n 2nd\n 12 GB\n 73%\n \n \n 2024-01-14\n $24.99\n 3rd\n 10 GB\n 82%\n \n \n 2024-01-16\n $24.99\n 3rd\n 8 GB\n 99%\n \n \n \n \n\n\n\n\n\n\nQuarto automatically applies some data processing to the content of the tables it renders. By default, tinytable disables this processing, because it can enter in conflict with styling and formatting features of the package.\nTo enable Quarto data processing, we can use the quarto argument of the format_tt() function. This argument allows users to mark certain cells explicitly for processing by Quarto, by wrapping them in a special “span” called “data-qmd”, supported by Quarto:\n\nk <- data.frame(Thing = \"qwerty\", Citation = \"@Lovelace1842\")\n\ntt(k) |> format_tt(quarto = TRUE)\n\n\n\n \n \n \n \n\n \n\n \n \n \n\n\n\nThing\nCitation\n\n\n\n\nqwerty\nLovelace (1842)\n\n\n\n\n \n\n\n\nSome users may want to apply Quarto data processing to all tables. This can be done with themes:\n\ntheme_quarto <- function(x) format_tt(x, quarto = TRUE)\noptions(tinytable_tt_theme = theme_quarto)\n\ntt(k)\n\n\n\n \n \n \n \n\n \n\n \n \n \n\n\n\nThing\nCitation\n\n\n\n\nqwerty\nLovelace (1842)\n\n\n\n\n \n\n\n\nBack to normal:\n\noptions(tinytable_tt_theme = NULL)\n\nAlternatively, users can set a global option to process all tables in Quarto, but they will then have to mark each cell with special content using format_tt(quarto):\n\noptions(tinytable_quarto_disable_processing = FALSE)\n\ntt(x)\n\n\n\n \n \n \n \n\n \n\n \n \n \n\n\n\nmpg\ncyl\ndisp\nhp\ndrat\n\n\n\n\n21.0\n6\n160\n110\n3.90\n\n\n21.0\n6\n160\n110\n3.90\n\n\n22.8\n4\n108\n93\n3.85\n\n\n21.4\n6\n258\n110\n3.08\n\n\n\n\n \n\n\n\nNotice that Quarto is now processing the table, so we lose the default tinytable theme and get the default striped Quarto look.\nBack to normal:\n\noptions(tinytable_quarto_disable_processing = TRUE)",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -651,7 +651,7 @@
"href": "vignettes/format.html#numbers-dates-strings-etc.",
"title": "Formatting",
"section": "",
- "text": "The tt() function is minimalist; it’s inteded purpose is simply to draw nice tables. Users who want to format numbers, dates, strings, and other variables in different ways should process their data before supplying it to the tt() table-drawing function. To do so, we can use the format_tt() function supplied by the tinytable.\nIn a very simple case—such as printing 2 significant digits of all numeric variables—we can use the digits argument of tt():\n\ndat <- data.frame(\n w = c(143002.2092, 201399.181, 100188.3883),\n x = c(1.43402, 201.399, 0.134588),\n y = as.Date(sample(1:1000, 3), origin = \"1970-01-01\"),\n z = c(TRUE, TRUE, FALSE))\n\ntt(dat, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143002\n 1.43\n 1971-03-08\n True \n \n \n 201399\n 201.4 \n 1970-08-16\n True \n \n \n 100188\n 0.13\n 1971-09-16\n False\n \n \n \n \n\n\n\nWe can get more fine-grained control over formatting by calling format_tt() after tt(), optionally by specifying the columns to format with j:\n\ntt(dat) |> \n format_tt(\n j = 2:4,\n digits = 1,\n date = \"%B %d %Y\") |>\n format_tt(\n j = 1,\n digits = 2,\n num_mark_big = \" \",\n num_mark_dec = \",\",\n num_fmt = \"decimal\")\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143 002,21\n 1.4\n March 08 1971\n True\n \n \n 201 399,18\n 201.4\n August 16 1970\n True\n \n \n 100 188,39\n 0.1\n September 16 1971\n False\n \n \n \n \n\n\n\nWe can use a regular expression in j to select columns, and the ?sprintf function to format strings, numbers, and to do string interpolation (similar to the glue package, but using Base R):\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.432\n 99T\n \n \n Food: Halloumi\n 201.399\n 7.3B\n \n \n Food: Tofu\n 0.146\n 29M\n \n \n Food: Beans\n 0.003\n 94K\n \n \n \n \n\n\n\nFinally, if you like the format_tt() interface, you can use it directly with numbers, vectors, or data frames:\n\nformat_tt(pi, digits = 1)\n\n[1] \"3\"\n\nformat_tt(dat, digits = 1, num_suffix = TRUE)\n\n a b c\n1 Burger 1 99T\n2 Halloumi 201 7B\n3 Tofu 0.1 29M\n4 Beans 0.003 94K",
+ "text": "The tt() function is minimalist; it’s inteded purpose is simply to draw nice tables. Users who want to format numbers, dates, strings, and other variables in different ways should process their data before supplying it to the tt() table-drawing function. To do so, we can use the format_tt() function supplied by the tinytable.\nIn a very simple case—such as printing 2 significant digits of all numeric variables—we can use the digits argument of tt():\n\ndat <- data.frame(\n w = c(143002.2092, 201399.181, 100188.3883),\n x = c(1.43402, 201.399, 0.134588),\n y = as.Date(sample(1:1000, 3), origin = \"1970-01-01\"),\n z = c(TRUE, TRUE, FALSE))\n\ntt(dat, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143002\n 1.43\n 1971-10-17\n True \n \n \n 201399\n 201.4 \n 1970-12-24\n True \n \n \n 100188\n 0.13\n 1971-12-13\n False\n \n \n \n \n\n\n\nWe can get more fine-grained control over formatting by calling format_tt() after tt(), optionally by specifying the columns to format with j:\n\ntt(dat) |> \n format_tt(\n j = 2:4,\n digits = 1,\n date = \"%B %d %Y\") |>\n format_tt(\n j = 1,\n digits = 2,\n num_mark_big = \" \",\n num_mark_dec = \",\",\n num_fmt = \"decimal\")\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143 002,21\n 1.4\n October 17 1971\n True\n \n \n 201 399,18\n 201.4\n December 24 1970\n True\n \n \n 100 188,39\n 0.1\n December 13 1971\n False\n \n \n \n \n\n\n\nWe can use a regular expression in j to select columns, and the ?sprintf function to format strings, numbers, and to do string interpolation (similar to the glue package, but using Base R):\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.432\n 99T\n \n \n Food: Halloumi\n 201.399\n 7.3B\n \n \n Food: Tofu\n 0.146\n 29M\n \n \n Food: Beans\n 0.003\n 94K\n \n \n \n \n\n\n\nFinally, if you like the format_tt() interface, you can use it directly with numbers, vectors, or data frames:\n\nformat_tt(pi, digits = 1)\n\n[1] \"3\"\n\nformat_tt(dat, digits = 1, num_suffix = TRUE)\n\n a b c\n1 Burger 1 99T\n2 Halloumi 201 7B\n3 Tofu 0.1 29M\n4 Beans 0.003 94K",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -1082,7 +1082,7 @@
"href": "man/group_tt.html",
"title": "tinytable",
"section": "",
- "text": "Spanning labels to identify groups of rows or columns\n\n\n\ngroup_tt(x, i = NULL, j = NULL, indent = 1, ...)\n\n\n\n\n\n\n\nx\n\n\nA data frame or data table to be rendered as a table.\n\n\n\n\ni\n\n\nA vector of labels with length equal to the number of rows in x, or a named list of row indices to group. The names of the list will be used as labels. The indices represent the position where labels should be inserted in the original table. For example,\n\n\ni=list(“Hello”=5): insert the \"Hello\" label after the 4th row in the original table.\n\n\ni=list(“Hello”=2, “World”=2): insert the two labels consecutively after the 1st row in the original table.\n\n\ni=list(“Foo Bar”=0): insert the label in the first row after the header.\n\n\n\n\n\n\nj\n\n\nA named list of column indices to group. The names of the list will be used as labels. See examples below. Note: empty labels must be a space: \" \".\n\n\n\n\nindent\n\n\ninteger number of pt to use when indenting the non-labelled rows.\n\n\n\n\n…\n\n\nOther arguments are ignored.\n\n\n\n\n\n\nWarning: The style_tt() can normally be used to style the group headers, as expected, but that feature is not available for Markdown and Word tables.\n\n\n\nAn object of class tt representing the table.\n\n\n\n\nlibrary(\"tinytable\")\n\n\n# vector of row labels\ndat <- data.frame(\n label = c(\"a\", \"a\", \"a\", \"b\", \"b\", \"c\", \"a\", \"a\"),\n x1 = rnorm(8),\n x2 = rnorm(8))\ntt(dat[, 2:3]) |> group_tt(i = dat$label)\n\n\n\n \n\n \n \n \n \n \n \n x1\n x2\n \n \n \n \n \n -1.0078862\n 0.4352756\n \n \n 1.4752168\n 0.9104151\n \n \n -0.8107267\n -0.2365799\n \n \n -1.2232999\n 0.1458874\n \n \n 0.9005819\n -0.6132735\n \n \n -0.1360992\n -1.1905177\n \n \n -0.6259448\n -1.0824529\n \n \n 0.6234085\n 0.3027523\n \n \n \n \n\n\n# named lists of labels\ntt(mtcars[1:10, 1:5]) |>\n group_tt(\n i = list(\n \"Hello\" = 3,\n \"World\" = 8),\n j = list(\n \"Foo\" = 2:3,\n \"Bar\" = 4:5))\n\n\n\n \n\n \n \n \n \n\n \nFoo\nBar\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n \n \n 19.2\n 6\n 167.6\n 123\n 3.92\n \n \n \n \n\n\ndat <- mtcars[1:9, 1:8]\ntt(dat) |>\n group_tt(i = list(\n \"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7))\n\n\n\n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\ntt(dat) |>\n group_tt(\n j = list(\n \"Hamburgers\" = 1:3,\n \"Halloumi\" = 4:5,\n \"Tofu\" = 7))\n\n\n\n \n\n \n \n \n \n\nHamburgers\nHalloumi\n \nTofu\n \n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\nx <- mtcars[1:5, 1:6]\ntt(x) |>\n group_tt(j = list(\"Hello\" = 1:2, \"World\" = 3:4, \"Hello\" = 5:6)) |>\n group_tt(j = list(\"Foo\" = 1:3, \"Bar\" = 4:6))\n\n\n\n \n\n \n \n \n \n\nFoo\nBar\n\n\nHello\nWorld\nHello\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.620\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.875\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.320\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.215\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.440",
+ "text": "Spanning labels to identify groups of rows or columns\n\n\n\ngroup_tt(x, i = NULL, j = NULL, indent = 1, ...)\n\n\n\n\n\n\n\nx\n\n\nA data frame or data table to be rendered as a table.\n\n\n\n\ni\n\n\nA vector of labels with length equal to the number of rows in x, or a named list of row indices to group. The names of the list will be used as labels. The indices represent the position where labels should be inserted in the original table. For example,\n\n\ni=list(“Hello”=5): insert the \"Hello\" label after the 4th row in the original table.\n\n\ni=list(“Hello”=2, “World”=2): insert the two labels consecutively after the 1st row in the original table.\n\n\ni=list(“Foo Bar”=0): insert the label in the first row after the header.\n\n\n\n\n\n\nj\n\n\nA named list of column indices to group. The names of the list will be used as labels. See examples below. Note: empty labels must be a space: \" \".\n\n\n\n\nindent\n\n\ninteger number of pt to use when indenting the non-labelled rows.\n\n\n\n\n…\n\n\nOther arguments are ignored.\n\n\n\n\n\n\nWarning: The style_tt() can normally be used to style the group headers, as expected, but that feature is not available for Markdown and Word tables.\n\n\n\nAn object of class tt representing the table.\n\n\n\n\nlibrary(\"tinytable\")\n\n\n# vector of row labels\ndat <- data.frame(\n label = c(\"a\", \"a\", \"a\", \"b\", \"b\", \"c\", \"a\", \"a\"),\n x1 = rnorm(8),\n x2 = rnorm(8))\ntt(dat[, 2:3]) |> group_tt(i = dat$label)\n\n\n\n \n\n \n \n \n \n \n \n x1\n x2\n \n \n \n \n \n -1.2928994\n 0.3438932\n \n \n -0.2131877\n 0.9079434\n \n \n -1.0560067\n 0.8225227\n \n \n 1.0793180\n -1.9694722\n \n \n -0.0945106\n 0.5980063\n \n \n 1.8215610\n 0.2414946\n \n \n 1.1239596\n 1.0194036\n \n \n -1.6838725\n -1.0095785\n \n \n \n \n\n\n# named lists of labels\ntt(mtcars[1:10, 1:5]) |>\n group_tt(\n i = list(\n \"Hello\" = 3,\n \"World\" = 8),\n j = list(\n \"Foo\" = 2:3,\n \"Bar\" = 4:5))\n\n\n\n \n\n \n \n \n \n\n \nFoo\nBar\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n \n \n 19.2\n 6\n 167.6\n 123\n 3.92\n \n \n \n \n\n\ndat <- mtcars[1:9, 1:8]\ntt(dat) |>\n group_tt(i = list(\n \"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7))\n\n\n\n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\ntt(dat) |>\n group_tt(\n j = list(\n \"Hamburgers\" = 1:3,\n \"Halloumi\" = 4:5,\n \"Tofu\" = 7))\n\n\n\n \n\n \n \n \n \n\nHamburgers\nHalloumi\n \nTofu\n \n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\nx <- mtcars[1:5, 1:6]\ntt(x) |>\n group_tt(j = list(\"Hello\" = 1:2, \"World\" = 3:4, \"Hello\" = 5:6)) |>\n group_tt(j = list(\"Foo\" = 1:3, \"Bar\" = 4:6))\n\n\n\n \n\n \n \n \n \n\nFoo\nBar\n\n\nHello\nWorld\nHello\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.620\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.875\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.320\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.215\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.440",
"crumbs": [
"Tutorial (PDF)",
"Functions",
@@ -1094,7 +1094,7 @@
"href": "man/group_tt.html#spanning-labels-to-identify-groups-of-rows-or-columns",
"title": "tinytable",
"section": "",
- "text": "Spanning labels to identify groups of rows or columns\n\n\n\ngroup_tt(x, i = NULL, j = NULL, indent = 1, ...)\n\n\n\n\n\n\n\nx\n\n\nA data frame or data table to be rendered as a table.\n\n\n\n\ni\n\n\nA vector of labels with length equal to the number of rows in x, or a named list of row indices to group. The names of the list will be used as labels. The indices represent the position where labels should be inserted in the original table. For example,\n\n\ni=list(“Hello”=5): insert the \"Hello\" label after the 4th row in the original table.\n\n\ni=list(“Hello”=2, “World”=2): insert the two labels consecutively after the 1st row in the original table.\n\n\ni=list(“Foo Bar”=0): insert the label in the first row after the header.\n\n\n\n\n\n\nj\n\n\nA named list of column indices to group. The names of the list will be used as labels. See examples below. Note: empty labels must be a space: \" \".\n\n\n\n\nindent\n\n\ninteger number of pt to use when indenting the non-labelled rows.\n\n\n\n\n…\n\n\nOther arguments are ignored.\n\n\n\n\n\n\nWarning: The style_tt() can normally be used to style the group headers, as expected, but that feature is not available for Markdown and Word tables.\n\n\n\nAn object of class tt representing the table.\n\n\n\n\nlibrary(\"tinytable\")\n\n\n# vector of row labels\ndat <- data.frame(\n label = c(\"a\", \"a\", \"a\", \"b\", \"b\", \"c\", \"a\", \"a\"),\n x1 = rnorm(8),\n x2 = rnorm(8))\ntt(dat[, 2:3]) |> group_tt(i = dat$label)\n\n\n\n \n\n \n \n \n \n \n \n x1\n x2\n \n \n \n \n \n -1.0078862\n 0.4352756\n \n \n 1.4752168\n 0.9104151\n \n \n -0.8107267\n -0.2365799\n \n \n -1.2232999\n 0.1458874\n \n \n 0.9005819\n -0.6132735\n \n \n -0.1360992\n -1.1905177\n \n \n -0.6259448\n -1.0824529\n \n \n 0.6234085\n 0.3027523\n \n \n \n \n\n\n# named lists of labels\ntt(mtcars[1:10, 1:5]) |>\n group_tt(\n i = list(\n \"Hello\" = 3,\n \"World\" = 8),\n j = list(\n \"Foo\" = 2:3,\n \"Bar\" = 4:5))\n\n\n\n \n\n \n \n \n \n\n \nFoo\nBar\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n \n \n 19.2\n 6\n 167.6\n 123\n 3.92\n \n \n \n \n\n\ndat <- mtcars[1:9, 1:8]\ntt(dat) |>\n group_tt(i = list(\n \"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7))\n\n\n\n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\ntt(dat) |>\n group_tt(\n j = list(\n \"Hamburgers\" = 1:3,\n \"Halloumi\" = 4:5,\n \"Tofu\" = 7))\n\n\n\n \n\n \n \n \n \n\nHamburgers\nHalloumi\n \nTofu\n \n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\nx <- mtcars[1:5, 1:6]\ntt(x) |>\n group_tt(j = list(\"Hello\" = 1:2, \"World\" = 3:4, \"Hello\" = 5:6)) |>\n group_tt(j = list(\"Foo\" = 1:3, \"Bar\" = 4:6))\n\n\n\n \n\n \n \n \n \n\nFoo\nBar\n\n\nHello\nWorld\nHello\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.620\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.875\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.320\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.215\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.440",
+ "text": "Spanning labels to identify groups of rows or columns\n\n\n\ngroup_tt(x, i = NULL, j = NULL, indent = 1, ...)\n\n\n\n\n\n\n\nx\n\n\nA data frame or data table to be rendered as a table.\n\n\n\n\ni\n\n\nA vector of labels with length equal to the number of rows in x, or a named list of row indices to group. The names of the list will be used as labels. The indices represent the position where labels should be inserted in the original table. For example,\n\n\ni=list(“Hello”=5): insert the \"Hello\" label after the 4th row in the original table.\n\n\ni=list(“Hello”=2, “World”=2): insert the two labels consecutively after the 1st row in the original table.\n\n\ni=list(“Foo Bar”=0): insert the label in the first row after the header.\n\n\n\n\n\n\nj\n\n\nA named list of column indices to group. The names of the list will be used as labels. See examples below. Note: empty labels must be a space: \" \".\n\n\n\n\nindent\n\n\ninteger number of pt to use when indenting the non-labelled rows.\n\n\n\n\n…\n\n\nOther arguments are ignored.\n\n\n\n\n\n\nWarning: The style_tt() can normally be used to style the group headers, as expected, but that feature is not available for Markdown and Word tables.\n\n\n\nAn object of class tt representing the table.\n\n\n\n\nlibrary(\"tinytable\")\n\n\n# vector of row labels\ndat <- data.frame(\n label = c(\"a\", \"a\", \"a\", \"b\", \"b\", \"c\", \"a\", \"a\"),\n x1 = rnorm(8),\n x2 = rnorm(8))\ntt(dat[, 2:3]) |> group_tt(i = dat$label)\n\n\n\n \n\n \n \n \n \n \n \n x1\n x2\n \n \n \n \n \n -1.2928994\n 0.3438932\n \n \n -0.2131877\n 0.9079434\n \n \n -1.0560067\n 0.8225227\n \n \n 1.0793180\n -1.9694722\n \n \n -0.0945106\n 0.5980063\n \n \n 1.8215610\n 0.2414946\n \n \n 1.1239596\n 1.0194036\n \n \n -1.6838725\n -1.0095785\n \n \n \n \n\n\n# named lists of labels\ntt(mtcars[1:10, 1:5]) |>\n group_tt(\n i = list(\n \"Hello\" = 3,\n \"World\" = 8),\n j = list(\n \"Foo\" = 2:3,\n \"Bar\" = 4:5))\n\n\n\n \n\n \n \n \n \n\n \nFoo\nBar\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n \n \n 19.2\n 6\n 167.6\n 123\n 3.92\n \n \n \n \n\n\ndat <- mtcars[1:9, 1:8]\ntt(dat) |>\n group_tt(i = list(\n \"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7))\n\n\n\n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\ntt(dat) |>\n group_tt(\n j = list(\n \"Hamburgers\" = 1:3,\n \"Halloumi\" = 4:5,\n \"Tofu\" = 7))\n\n\n\n \n\n \n \n \n \n\nHamburgers\nHalloumi\n \nTofu\n \n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\nx <- mtcars[1:5, 1:6]\ntt(x) |>\n group_tt(j = list(\"Hello\" = 1:2, \"World\" = 3:4, \"Hello\" = 5:6)) |>\n group_tt(j = list(\"Foo\" = 1:3, \"Bar\" = 4:6))\n\n\n\n \n\n \n \n \n \n\nFoo\nBar\n\n\nHello\nWorld\nHello\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.620\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.875\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.320\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.215\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.440",
"crumbs": [
"Tutorial (PDF)",
"Functions",
diff --git a/vignettes/custom.html b/vignettes/custom.html
index fd76549b..9553fcb5 100644
--- a/vignettes/custom.html
+++ b/vignettes/custom.html
@@ -427,12 +427,12 @@ Bootstrap classes
-
+
@@ -532,12 +532,12 @@ Bootstrap classes
-
+
@@ -638,12 +638,12 @@ Bootstrap classes
-
+
@@ -747,12 +747,12 @@ CSS declarations
-
+
@@ -898,12 +898,12 @@ CSS rules
-
+
@@ -1067,12 +1067,12 @@ CSS rules
-
+
diff --git a/vignettes/format.html b/vignettes/format.html
index edc3f701..aa80cc50 100644
--- a/vignettes/format.html
+++ b/vignettes/format.html
@@ -446,12 +446,12 @@ Numbers, dates,
-
+
@@ -511,19 +511,19 @@ Numbers, dates,
143002 |
1.43 |
- 1971-03-08 |
+ 1971-10-17 |
True |
201399 |
201.4 |
- 1970-08-16 |
+ 1970-12-24 |
True |
100188 |
0.13 |
- 1971-09-16 |
+ 1971-12-13 |
False |
@@ -549,12 +549,12 @@ Numbers, dates,
-
+
@@ -614,19 +614,19 @@ Numbers, dates,
143 002,21 |
1.4 |
- March 08 1971 |
+ October 17 1971 |
True |
201 399,18 |
201.4 |
- August 16 1970 |
+ December 24 1970 |
True |
100 188,39 |
0.1 |
- September 16 1971 |
+ December 13 1971 |
False |
@@ -649,12 +649,12 @@ Numbers, dates,
-
+
@@ -761,12 +761,12 @@ Significan
-
+
@@ -836,12 +836,12 @@ Significan
-
+
@@ -913,12 +913,12 @@ Significan
-
+
@@ -1013,12 +1013,12 @@ Math
-
+
@@ -1109,12 +1109,12 @@ Math
-
+
@@ -1203,12 +1203,12 @@ Replacement
-
+
@@ -1297,12 +1297,12 @@ Replacement
-
+
@@ -1391,12 +1391,12 @@ Replacement
-
+
@@ -1490,12 +1490,12 @@ Replacement
-
+
@@ -1603,12 +1603,12 @@ Escape special c
-
+
@@ -1717,12 +1717,12 @@ Markdown
-
+
@@ -1839,12 +1839,12 @@ Markdown
-
Vincent sometimes contributes to these R packages.
+ Vincent sometimes contributes to these R packages.
@@ -1973,12 +1973,12 @@ Custom functions
-
+
@@ -2107,12 +2107,12 @@ Custom functions
-
+
@@ -2232,12 +2232,12 @@ Quarto data process