diff --git a/CITATION.html b/CITATION.html
index 30716056..1e87fb00 100644
--- a/CITATION.html
+++ b/CITATION.html
@@ -348,7 +348,7 @@
Citation
Arel-Bundock V (????). _tinytable: Simple and Configurable Tables in
'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', and 'Typst'
- Formats_. R package version 0.3.0.7,
+ Formats_. R package version 0.3.0.8,
<https://vincentarelbundock.github.io/tinytable/>.
A BibTeX entry for LaTeX users is
@@ -356,7 +356,7 @@ Citation
@Manual{,
title = {tinytable: Simple and Configurable Tables in 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', and 'Typst' Formats},
author = {Vincent Arel-Bundock},
- note = {R package version 0.3.0.7},
+ note = {R package version 0.3.0.8},
url = {https://vincentarelbundock.github.io/tinytable/},
}
diff --git a/NEWS.html b/NEWS.html
index 70fffbb9..19e45cdb 100644
--- a/NEWS.html
+++ b/NEWS.html
@@ -360,6 +360,7 @@ News
Development
+group_tt()
allows 0 and duplicates in i
argument for labels in the first row and consecutive labels.
- Headers are now styled and formatted when
i=NULL
.
colnames(x)<-NULL
works on a tinytable
object.
format_tt(num_big_mark)
applies to integer columns.
diff --git a/index.html b/index.html
index 5c840159..f48c04ef 100644
--- a/index.html
+++ b/index.html
@@ -446,7 +446,7 @@ First steps
Tutorial
-The tinytable
0.3.0.7 tutorial will take you much further. It is available in two formats:
+The tinytable
0.3.0.8 tutorial will take you much further. It is available in two formats:
- Tutorial (PDF)
- Tutorial (HTML):
diff --git a/man/format_tt.html b/man/format_tt.html
index 50eac360..bb049d55 100644
--- a/man/format_tt.html
+++ b/man/format_tt.html
@@ -670,9 +670,9 @@
Examples
- tinytable_1qw0qru5e95a20fvutzu
+ tinytable_fo2mzsmwyubzv6l7w55b
@@ -690,7 +690,7 @@ Examples
-
+
@@ -701,28 +701,28 @@ Examples
- 10 000 |
10 001 |
+ 9 999 |
- 10 000 |
- 10 000 |
+ 10 001 |
+ 9 998 |
10 000 |
- 9 999 |
+ 10 002 |
@@ -774,9 +774,9 @@ Examples
- tinytable_2eg48c1ekoz54lriwlgn
+ tinytable_bjgrk8lwzqxdd400d3do
@@ -794,7 +794,7 @@ Examples
-
+
@@ -814,12 +814,12 @@ Examples
@@ -876,9 +876,9 @@ Examples
- tinytable_zevl7x5xliwvknozrqbm
+ tinytable_u6mr9vgc8nnatn3jaain
@@ -896,7 +896,7 @@ Examples
-
+
@@ -932,12 +932,12 @@ Examples
@@ -990,9 +990,9 @@ Examples
- tinytable_brpyts5e5c79i22ulef9
+ tinytable_nuz9vdo8nd525kctr7ht
@@ -1010,7 +1010,7 @@ Examples
-
+
@@ -1030,12 +1030,12 @@ Examples
@@ -1086,9 +1086,9 @@ Examples
- tinytable_nd3zv6mixpo7ubr47tgc
+ tinytable_8k78m27pf0xgtjinn26x
@@ -1106,7 +1106,7 @@ Examples
-
+
@@ -1126,12 +1126,12 @@ Examples
@@ -1182,9 +1182,9 @@ Examples
- tinytable_1c4udocrldhy79m57bqh
+ tinytable_2k39h6tt5yqfl0xx34bo
@@ -1202,7 +1202,7 @@ Examples
-
+
@@ -1229,12 +1229,12 @@ Examples
@@ -1289,9 +1289,9 @@ Examples
- tinytable_l9n3cxj3rn861pfy60mq
+ tinytable_43pf9o0mhbpwjw2pays8
@@ -1309,7 +1309,7 @@ Examples
-
+
@@ -1336,12 +1336,12 @@ Examples
diff --git a/man/group_tt.html b/man/group_tt.html
index b4a02f45..d9c3d7be 100644
--- a/man/group_tt.html
+++ b/man/group_tt.html
@@ -480,13 +480,13 @@ Examples
- tinytable_fxc97k767y6mtccgegdw
+ tinytable_0qhd6tjiceh9ryy73qwn
@@ -504,7 +504,7 @@ Examples
-
+
|
@@ -597,12 +597,12 @@ Examples
@@ -685,11 +685,11 @@ Examples
- tinytable_vkamaf3u0jjlr1nsm1oa
+ tinytable_xhvoeupi21m10t1qrps1
@@ -707,7 +707,7 @@ Examples
-
+
@@ -818,12 +818,12 @@ Examples
@@ -905,11 +905,11 @@ Examples
- tinytable_1n38lzwkkpevwddc624g
+ tinytable_451cd351owzmggefww6x
@@ -927,7 +927,7 @@ Examples
-
+
Hamburgers |
@@ -1045,12 +1045,12 @@ Examples
@@ -1121,13 +1121,13 @@ Examples
- tinytable_hp07p2bzeom5a2iui8fd
+ tinytable_jcsg566npcajfybupaus
@@ -1145,7 +1145,7 @@ Examples
-
+
Foo |
@@ -1213,12 +1213,12 @@ Examples
diff --git a/man/rbind2-tinytable-tinytable-method.html b/man/rbind2-tinytable-tinytable-method.html
index 39d5baa2..7460ee10 100644
--- a/man/rbind2-tinytable-tinytable-method.html
+++ b/man/rbind2-tinytable-tinytable-method.html
@@ -485,9 +485,9 @@ Examples
- tinytable_0io1f4ab32wwqvlf6qs5
+ tinytable_7hcagka06xptowqmx249
@@ -505,7 +505,7 @@ Examples
-
+
Combine two tiny tables.
@@ -565,12 +565,12 @@ Examples
@@ -624,9 +624,9 @@ Examples
- tinytable_qg6xcgvkth15bvt0jlv0
+ tinytable_gv3lctrjm62uon6ol2po
@@ -644,7 +644,7 @@ Examples
-
+
Combine two tiny tables.
@@ -704,12 +704,12 @@ Examples
@@ -764,9 +764,9 @@ Examples
- tinytable_awb1n9cwtb15qfnfxloy
+ tinytable_vvyihltengei44kjvz27
@@ -784,7 +784,7 @@ Examples
-
+
Combine two tiny tables.
@@ -837,12 +837,12 @@ Examples
@@ -897,9 +897,9 @@ Examples
- tinytable_rqdcdu4helgpe0vfkrjv
+ tinytable_r4zjkbkilbv41g5a5uo6
@@ -917,7 +917,7 @@ Examples
-
+
Combine two tiny tables.
@@ -963,12 +963,12 @@ Examples
diff --git a/man/theme_tt.html b/man/theme_tt.html
index 05746ba1..ee0af041 100644
--- a/man/theme_tt.html
+++ b/man/theme_tt.html
@@ -505,7 +505,7 @@ Examples
- tinytable_jz7ym5bi2ruz8nvqi3nz
+ tinytable_0jhl9x1039iawivnq4fo
@@ -524,7 +524,7 @@ Examples
-
+
@@ -565,12 +565,12 @@ Examples
@@ -639,7 +639,7 @@ Examples
-
+
@@ -680,12 +680,12 @@ Examples
diff --git a/man/tt.html b/man/tt.html
index 88a986cc..93d3c8ee 100644
--- a/man/tt.html
+++ b/man/tt.html
@@ -591,9 +591,9 @@ Examples
- tinytable_g6r84r5wkqo3f48e07yg
+ tinytable_x23mayhr3r9toesv2nc2
@@ -611,7 +611,7 @@ Examples
-
+
@@ -657,12 +657,12 @@ Examples
@@ -719,7 +719,7 @@ Examples
- tinytable_2c0x4b0dpfjoaldh68l9
+ tinytable_t42bj77w01ywpyb7ygcr
@@ -738,7 +738,7 @@ Examples
-
+
Data about cars.
@@ -784,12 +784,12 @@ Examples
@@ -858,7 +858,7 @@ Examples
-
+
@@ -904,12 +904,12 @@ Examples
@@ -987,9 +987,9 @@ Examples
- tinytable_3s6bu3z5djmeu2ao3h73
+ tinytable_rtem9rp6j5mkstpt6lvc
@@ -1007,7 +1007,7 @@ Examples
-
+
@@ -1027,12 +1027,12 @@ Examples
diff --git a/search.json b/search.json
index 2a0a5736..c6a7893d 100644
--- a/search.json
+++ b/search.json
@@ -16,7 +16,7 @@
"href": "vignettes/custom.html",
"title": "Customization",
"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\n\n\nThe Bootstrap framework provides a number of built-in themes to style tables, using “classes.” To use them, we call style_tt() with the bootstrap_class argument. A list of available Bootstrap classes can be found here: https://getbootstrap.com/docs/5.3/content/tables/\nFor example, to produce a “bordered” table, we use the table-bordered class:\n\ntt(x) |> style_tt(bootstrap_class = \"table table-bordered\")\n\n \n\n \n \n \n tinytable_3e0u7g9b9p5ddva6xk1u\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also combine several Bootstrap classes. Here, we get a table with the “hover” feature:\n\ntt(x) |> style_tt(\n bootstrap_class = \"table table-hover\")\n\n \n\n \n \n \n tinytable_530vwuanroz6wim1q7mw\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe style_tt() function allows us to declare CSS properties and values for individual cells, columns, or rows of a table. For example, if we want to make the first column bold, we could do:\n\ntt(x) |>\n style_tt(j = 1, bootstrap_css = \"font-weight: bold; color: red;\")\n\n \n\n \n \n \n tinytable_nus0g3m796xljgoalz2k\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nFor 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.\n\ncss_rule <- \"\n.mytable {\n background: linear-gradient(45deg, #EA8D8D, #A890FE);\n width: 600px;\n border-collapse: collapse;\n overflow: hidden;\n box-shadow: 0 0 20px rgba(0,0,0,0.1);\n}\n\n.mytable th,\n.mytable td {\n padding: 5px;\n background-color: rgba(255,255,255,0.2);\n color: #fff;\n}\n\n.mytable tbody tr:hover {\n background-color: rgba(255,255,255,0.3);\n}\n\n.mytable tbody td:hover:before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: -9999px;\n bottom: -9999px;\n background-color: rgba(255,255,255,0.2);\n z-index: -1;\n}\n\"\n\ntt(x, width = 2/3) |> \n style_tt(\n j = 1:5,\n align = \"ccccc\",\n bootstrap_class = \"table mytable\",\n bootstrap_css_rule = css_rule)\n\n \n\n \n \n \n tinytable_2ns30eohq27xcf8xxv67\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nAnd here’s another example:\n\ncss <- \"\n.squirreltable {\n background-size: cover;\n background-position: center;\n background-image: url('https://user-images.githubusercontent.com/987057/82732352-b9aabf00-9cda-11ea-92a6-26750cf097d0.png');\n --bs-table-bg: transparent;\n}\n\"\n\ntt(mtcars[1:10, 1:8]) |>\n style_tt(\n bootstrap_class = \"table table-borderless squirreltable\", \n bootstrap_css_rule = css)\n\n \n\n \n \n \n tinytable_kvouezskaiyagnla3617\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n 19.2\n 6\n 168\n 123\n 3.92\n 3.44\n 18.3\n 1\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\n\nThe LaTeX / PDF customization options described in this section are not available for HTML documents. Please refer to the PDF documentation hosted on the website to read this part of the tutorial.\n\n\n\n\n\n\n\n\n\n\n\n\ntinytable is a great complement to Shiny for displaying HTML tables in a web app. The styling in a tinytable is applied by JavaScript functions and CSS. Thus, to ensure that this styling is preserved in a Shiny app, one strategy is to bake the entire page, save it in a temporary file, and load it using the includeHTML function from the shiny package. This approach is illustrated in this minimal example:\n\nlibrary(\"shiny\")\nlibrary(\"tinytable\")\n\nfn <- paste(tempfile(), \".html\")\ntab <- tt(mtcars[1:5, 1:4]) |> \n style_tt(i = 0:5, color = \"orange\", background = \"black\") |> \n save_tt(fn) \n\nshinyApp(\n ui = fluidPage(\n fluidRow(column(12, h1(\"This is test of tinytable\"), \n shiny::includeHTML(fn)))), \n server = function(input, output) { \n }\n)",
+ "text": "library(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\nx <- mtcars[1:4, 1:5]\n\n\n\n\n\nThe Bootstrap framework provides a number of built-in themes to style tables, using “classes.” To use them, we call style_tt() with the bootstrap_class argument. A list of available Bootstrap classes can be found here: https://getbootstrap.com/docs/5.3/content/tables/\nFor example, to produce a “bordered” table, we use the table-bordered class:\n\ntt(x) |> style_tt(bootstrap_class = \"table table-bordered\")\n\n \n\n \n \n \n tinytable_h0oen9cakfq5ntbl3a1r\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also combine several Bootstrap classes. Here, we get a table with the “hover” feature:\n\ntt(x) |> style_tt(\n bootstrap_class = \"table table-hover\")\n\n \n\n \n \n \n tinytable_boulqpedg1wcjbgwsi3x\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe style_tt() function allows us to declare CSS properties and values for individual cells, columns, or rows of a table. For example, if we want to make the first column bold, we could do:\n\ntt(x) |>\n style_tt(j = 1, bootstrap_css = \"font-weight: bold; color: red;\")\n\n \n\n \n \n \n tinytable_b7n93jhgvttkqevwvyk7\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nFor 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.\n\ncss_rule <- \"\n.mytable {\n background: linear-gradient(45deg, #EA8D8D, #A890FE);\n width: 600px;\n border-collapse: collapse;\n overflow: hidden;\n box-shadow: 0 0 20px rgba(0,0,0,0.1);\n}\n\n.mytable th,\n.mytable td {\n padding: 5px;\n background-color: rgba(255,255,255,0.2);\n color: #fff;\n}\n\n.mytable tbody tr:hover {\n background-color: rgba(255,255,255,0.3);\n}\n\n.mytable tbody td:hover:before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: -9999px;\n bottom: -9999px;\n background-color: rgba(255,255,255,0.2);\n z-index: -1;\n}\n\"\n\ntt(x, width = 2/3) |> \n style_tt(\n j = 1:5,\n align = \"ccccc\",\n bootstrap_class = \"table mytable\",\n bootstrap_css_rule = css_rule)\n\n \n\n \n \n \n tinytable_p83rtkjy84s8neaow42f\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nAnd here’s another example:\n\ncss <- \"\n.squirreltable {\n background-size: cover;\n background-position: center;\n background-image: url('https://user-images.githubusercontent.com/987057/82732352-b9aabf00-9cda-11ea-92a6-26750cf097d0.png');\n --bs-table-bg: transparent;\n}\n\"\n\ntt(mtcars[1:10, 1:8]) |>\n style_tt(\n bootstrap_class = \"table table-borderless squirreltable\", \n bootstrap_css_rule = css)\n\n \n\n \n \n \n tinytable_mfr0io0dgoo99dvlhmvs\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n 19.2\n 6\n 168\n 123\n 3.92\n 3.44\n 18.3\n 1\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\n\nThe LaTeX / PDF customization options described in this section are not available for HTML documents. Please refer to the PDF documentation hosted on the website to read this part of the tutorial.\n\n\n\n\n\n\n\n\n\n\n\n\ntinytable is a great complement to Shiny for displaying HTML tables in a web app. The styling in a tinytable is applied by JavaScript functions and CSS. Thus, to ensure that this styling is preserved in a Shiny app, one strategy is to bake the entire page, save it in a temporary file, and load it using the includeHTML function from the shiny package. This approach is illustrated in this minimal example:\n\nlibrary(\"shiny\")\nlibrary(\"tinytable\")\n\nfn <- paste(tempfile(), \".html\")\ntab <- tt(mtcars[1:5, 1:4]) |> \n style_tt(i = 0:5, color = \"orange\", background = \"black\") |> \n save_tt(fn) \n\nshinyApp(\n ui = fluidPage(\n fluidRow(column(12, h1(\"This is test of tinytable\"), \n shiny::includeHTML(fn)))), \n server = function(input, output) { \n }\n)",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -28,7 +28,7 @@
"href": "vignettes/custom.html#html",
"title": "Customization",
"section": "",
- "text": "The Bootstrap framework provides a number of built-in themes to style tables, using “classes.” To use them, we call style_tt() with the bootstrap_class argument. A list of available Bootstrap classes can be found here: https://getbootstrap.com/docs/5.3/content/tables/\nFor example, to produce a “bordered” table, we use the table-bordered class:\n\ntt(x) |> style_tt(bootstrap_class = \"table table-bordered\")\n\n \n\n \n \n \n tinytable_3e0u7g9b9p5ddva6xk1u\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also combine several Bootstrap classes. Here, we get a table with the “hover” feature:\n\ntt(x) |> style_tt(\n bootstrap_class = \"table table-hover\")\n\n \n\n \n \n \n tinytable_530vwuanroz6wim1q7mw\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe style_tt() function allows us to declare CSS properties and values for individual cells, columns, or rows of a table. For example, if we want to make the first column bold, we could do:\n\ntt(x) |>\n style_tt(j = 1, bootstrap_css = \"font-weight: bold; color: red;\")\n\n \n\n \n \n \n tinytable_nus0g3m796xljgoalz2k\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nFor 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.\n\ncss_rule <- \"\n.mytable {\n background: linear-gradient(45deg, #EA8D8D, #A890FE);\n width: 600px;\n border-collapse: collapse;\n overflow: hidden;\n box-shadow: 0 0 20px rgba(0,0,0,0.1);\n}\n\n.mytable th,\n.mytable td {\n padding: 5px;\n background-color: rgba(255,255,255,0.2);\n color: #fff;\n}\n\n.mytable tbody tr:hover {\n background-color: rgba(255,255,255,0.3);\n}\n\n.mytable tbody td:hover:before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: -9999px;\n bottom: -9999px;\n background-color: rgba(255,255,255,0.2);\n z-index: -1;\n}\n\"\n\ntt(x, width = 2/3) |> \n style_tt(\n j = 1:5,\n align = \"ccccc\",\n bootstrap_class = \"table mytable\",\n bootstrap_css_rule = css_rule)\n\n \n\n \n \n \n tinytable_2ns30eohq27xcf8xxv67\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nAnd here’s another example:\n\ncss <- \"\n.squirreltable {\n background-size: cover;\n background-position: center;\n background-image: url('https://user-images.githubusercontent.com/987057/82732352-b9aabf00-9cda-11ea-92a6-26750cf097d0.png');\n --bs-table-bg: transparent;\n}\n\"\n\ntt(mtcars[1:10, 1:8]) |>\n style_tt(\n bootstrap_class = \"table table-borderless squirreltable\", \n bootstrap_css_rule = css)\n\n \n\n \n \n \n tinytable_kvouezskaiyagnla3617\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n 19.2\n 6\n 168\n 123\n 3.92\n 3.44\n 18.3\n 1",
+ "text": "The Bootstrap framework provides a number of built-in themes to style tables, using “classes.” To use them, we call style_tt() with the bootstrap_class argument. A list of available Bootstrap classes can be found here: https://getbootstrap.com/docs/5.3/content/tables/\nFor example, to produce a “bordered” table, we use the table-bordered class:\n\ntt(x) |> style_tt(bootstrap_class = \"table table-bordered\")\n\n \n\n \n \n \n tinytable_h0oen9cakfq5ntbl3a1r\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also combine several Bootstrap classes. Here, we get a table with the “hover” feature:\n\ntt(x) |> style_tt(\n bootstrap_class = \"table table-hover\")\n\n \n\n \n \n \n tinytable_boulqpedg1wcjbgwsi3x\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe style_tt() function allows us to declare CSS properties and values for individual cells, columns, or rows of a table. For example, if we want to make the first column bold, we could do:\n\ntt(x) |>\n style_tt(j = 1, bootstrap_css = \"font-weight: bold; color: red;\")\n\n \n\n \n \n \n tinytable_b7n93jhgvttkqevwvyk7\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nFor 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.\n\ncss_rule <- \"\n.mytable {\n background: linear-gradient(45deg, #EA8D8D, #A890FE);\n width: 600px;\n border-collapse: collapse;\n overflow: hidden;\n box-shadow: 0 0 20px rgba(0,0,0,0.1);\n}\n\n.mytable th,\n.mytable td {\n padding: 5px;\n background-color: rgba(255,255,255,0.2);\n color: #fff;\n}\n\n.mytable tbody tr:hover {\n background-color: rgba(255,255,255,0.3);\n}\n\n.mytable tbody td:hover:before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: -9999px;\n bottom: -9999px;\n background-color: rgba(255,255,255,0.2);\n z-index: -1;\n}\n\"\n\ntt(x, width = 2/3) |> \n style_tt(\n j = 1:5,\n align = \"ccccc\",\n bootstrap_class = \"table mytable\",\n bootstrap_css_rule = css_rule)\n\n \n\n \n \n \n tinytable_p83rtkjy84s8neaow42f\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nAnd here’s another example:\n\ncss <- \"\n.squirreltable {\n background-size: cover;\n background-position: center;\n background-image: url('https://user-images.githubusercontent.com/987057/82732352-b9aabf00-9cda-11ea-92a6-26750cf097d0.png');\n --bs-table-bg: transparent;\n}\n\"\n\ntt(mtcars[1:10, 1:8]) |>\n style_tt(\n bootstrap_class = \"table table-borderless squirreltable\", \n bootstrap_css_rule = css)\n\n \n\n \n \n \n tinytable_mfr0io0dgoo99dvlhmvs\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n 19.2\n 6\n 168\n 123\n 3.92\n 3.44\n 18.3\n 1",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -64,7 +64,7 @@
"href": "vignettes/group.html",
"title": "Groups and labels",
"section": "",
- "text": "library(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\nx <- mtcars[1:4, 1:5]\n\nThe group_tt() function can label groups of rows (i) or columns (j).\n\n\nThe 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:\n\ndat <- mtcars[1:9, 1:8]\n\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 tinytable_c8eiag9f6z1wg268mp8k\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\nThe numbers in the i list indicate that a label must be inserted at position # in the original table (without row groups). For example,\n\ntt(head(iris)) |>\n group_tt(i = list(\"After 1\" = 2, \"After 2\" = 3, \"After 3\" = 4, \"After 5\" = 6))\n\nWarning in `[<-.factor`(`*tmp*`, idx, value = \"\"): invalid factor level, NA\ngenerated\n\n\n \n\n \n \n \n tinytable_xmkgl3khin4u6kpjdf20\n \n \n \n \n \n\n \n \n \n \n \n \n Sepal.Length\n Sepal.Width\n Petal.Length\n Petal.Width\n Species\n \n \n \n \n \n 5.1\n 3.5\n 1.4\n 0.2\n setosa\n \n \n 4.9\n 3 \n 1.4\n 0.2\n setosa\n \n \n 4.7\n 3.2\n 1.3\n 0.2\n setosa\n \n \n 4.6\n 3.1\n 1.5\n 0.2\n setosa\n \n \n 5 \n 3.6\n 1.4\n 0.2\n setosa\n \n \n 5.4\n 3.9\n 1.7\n 0.4\n setosa\n \n \n \n \n\n \n\n \n\n\n\ntt(head(iris)) |>\n group_tt(i = list(\"After 1a\" = 2, \"After 1b\" = 2, \"After 5\" = 6))\n\nWarning in `[<-.factor`(`*tmp*`, idx, value = \"\"): invalid factor level, NA\ngenerated\n\n\n \n\n \n \n \n tinytable_5l6mnnbrbtjgbl0e4q3s\n \n \n \n \n \n\n \n \n \n \n \n \n Sepal.Length\n Sepal.Width\n Petal.Length\n Petal.Width\n Species\n \n \n \n \n \n 5.1\n 3.5\n 1.4\n 0.2\n setosa\n \n \n 4.9\n 3 \n 1.4\n 0.2\n setosa\n \n \n 4.7\n 3.2\n 1.3\n 0.2\n setosa\n \n \n 4.6\n 3.1\n 1.5\n 0.2\n setosa\n \n \n 5 \n 3.6\n 1.4\n 0.2\n setosa\n \n \n 5.4\n 3.9\n 1.7\n 0.4\n setosa\n \n \n \n \n\n \n\n \n\n\n\ntt(head(iris)) |>\n group_tt(i = list(\"After 0\" = 1))\n\nWarning in `[<-.factor`(`*tmp*`, idx, value = \"\"): invalid factor level, NA\ngenerated\n\n\n \n\n \n \n \n tinytable_6rd9an7purh509u5o04g\n \n \n \n \n \n\n \n \n \n \n \n \n Sepal.Length\n Sepal.Width\n Petal.Length\n Petal.Width\n Species\n \n \n \n \n \n 5.1\n 3.5\n 1.4\n 0.2\n setosa\n \n \n 4.9\n 3 \n 1.4\n 0.2\n setosa\n \n \n 4.7\n 3.2\n 1.3\n 0.2\n setosa\n \n \n 4.6\n 3.1\n 1.5\n 0.2\n setosa\n \n \n 5 \n 3.6\n 1.4\n 0.2\n setosa\n \n \n 5.4\n 3.9\n 1.7\n 0.4\n setosa\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style group rows in the same way as regular rows:\n\ntt(dat) |> \n group_tt(\n i = list(\n \"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7)) |>\n style_tt(\n i = c(3, 5, 9),\n align = \"c\",\n color = \"white\",\n background = \"gray\",\n bold = TRUE)\n\n \n\n \n \n \n tinytable_za6k80fvvaniwp9lgp93\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe 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:\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 tinytable_gz7cluhnpl32qkx8hml1\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\nHere is a table with both row and column headers, as well as some styling:\n\ndat <- mtcars[1:9, 1:8]\ntt(dat) |> \n group_tt(\n i = list(\"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7),\n j = list(\"Hamburgers\" = 1:3,\n \"Halloumi\" = 4:5,\n \"Tofu\" = 7)) |>\n style_tt(\n i = c(3, 5, 9),\n align = \"c\",\n background = \"teal\",\n color = \"white\") |>\n style_tt(i = -1, color = \"teal\")\n\n \n\n \n \n \n tinytable_mrjgast7cp2urtbo0raf\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also stack several extra headers on top of one another:\n\ntt(x) |>\n group_tt(j = list(\"Foo\" = 2:3, \"Bar\" = 5)) |>\n group_tt(j = list(\"Hello\" = 1:2, \"World\" = 4:5))\n\n \n\n \n \n \n tinytable_b2biib6yifsljysq0ufm\n \n \n \n \n \n\n \n \n \n \n\nHello\n \nWorld\n\n\n \nFoo\n \nBar\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
+ "text": "library(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\nx <- mtcars[1:4, 1:5]\n\nThe group_tt() function can label groups of rows (i) or columns (j).\n\n\nThe 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:\n\ndat <- mtcars[1:9, 1:8]\n\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 tinytable_xp60hoxwwisq7bno5twh\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\nThe numbers in the i list indicate that a label must be inserted at position # in the original table (without row groups). For example,\n\ntt(head(iris)) |>\n group_tt(i = list(\"After 1\" = 2, \"After 2\" = 3, \"After 3\" = 4, \"After 5\" = 6))\n\nWarning in `[<-.factor`(`*tmp*`, idx, value = \"\"): invalid factor level, NA\ngenerated\n\n\n \n\n \n \n \n tinytable_j6cqg0troahn9n70q2ry\n \n \n \n \n \n\n \n \n \n \n \n \n Sepal.Length\n Sepal.Width\n Petal.Length\n Petal.Width\n Species\n \n \n \n \n \n 5.1\n 3.5\n 1.4\n 0.2\n setosa\n \n \n 4.9\n 3 \n 1.4\n 0.2\n setosa\n \n \n 4.7\n 3.2\n 1.3\n 0.2\n setosa\n \n \n 4.6\n 3.1\n 1.5\n 0.2\n setosa\n \n \n 5 \n 3.6\n 1.4\n 0.2\n setosa\n \n \n 5.4\n 3.9\n 1.7\n 0.4\n setosa\n \n \n \n \n\n \n\n \n\n\n\ntt(head(iris)) |>\n group_tt(i = list(\"After 1a\" = 2, \"After 1b\" = 2, \"After 5\" = 6))\n\nWarning in `[<-.factor`(`*tmp*`, idx, value = \"\"): invalid factor level, NA\ngenerated\n\n\n \n\n \n \n \n tinytable_xzyf2iymg8uuojk41dat\n \n \n \n \n \n\n \n \n \n \n \n \n Sepal.Length\n Sepal.Width\n Petal.Length\n Petal.Width\n Species\n \n \n \n \n \n 5.1\n 3.5\n 1.4\n 0.2\n setosa\n \n \n 4.9\n 3 \n 1.4\n 0.2\n setosa\n \n \n 4.7\n 3.2\n 1.3\n 0.2\n setosa\n \n \n 4.6\n 3.1\n 1.5\n 0.2\n setosa\n \n \n 5 \n 3.6\n 1.4\n 0.2\n setosa\n \n \n 5.4\n 3.9\n 1.7\n 0.4\n setosa\n \n \n \n \n\n \n\n \n\n\n\ntt(head(iris)) |>\n group_tt(i = list(\"After 0\" = 1))\n\nWarning in `[<-.factor`(`*tmp*`, idx, value = \"\"): invalid factor level, NA\ngenerated\n\n\n \n\n \n \n \n tinytable_3ow0atlnpt0n80u3a52y\n \n \n \n \n \n\n \n \n \n \n \n \n Sepal.Length\n Sepal.Width\n Petal.Length\n Petal.Width\n Species\n \n \n \n \n \n 5.1\n 3.5\n 1.4\n 0.2\n setosa\n \n \n 4.9\n 3 \n 1.4\n 0.2\n setosa\n \n \n 4.7\n 3.2\n 1.3\n 0.2\n setosa\n \n \n 4.6\n 3.1\n 1.5\n 0.2\n setosa\n \n \n 5 \n 3.6\n 1.4\n 0.2\n setosa\n \n \n 5.4\n 3.9\n 1.7\n 0.4\n setosa\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style group rows in the same way as regular rows:\n\ntt(dat) |> \n group_tt(\n i = list(\n \"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7)) |>\n style_tt(\n i = c(3, 5, 9),\n align = \"c\",\n color = \"white\",\n background = \"gray\",\n bold = TRUE)\n\n \n\n \n \n \n tinytable_4pmjsj9e6h4vdsudp5t1\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe 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:\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 tinytable_y38y7pfrcz175no7sxw6\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\nHere is a table with both row and column headers, as well as some styling:\n\ndat <- mtcars[1:9, 1:8]\ntt(dat) |> \n group_tt(\n i = list(\"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7),\n j = list(\"Hamburgers\" = 1:3,\n \"Halloumi\" = 4:5,\n \"Tofu\" = 7)) |>\n style_tt(\n i = c(3, 5, 9),\n align = \"c\",\n background = \"teal\",\n color = \"white\") |>\n style_tt(i = -1, color = \"teal\")\n\n \n\n \n \n \n tinytable_mj7jims8y5iblai8dwe8\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also stack several extra headers on top of one another:\n\ntt(x) |>\n group_tt(j = list(\"Foo\" = 2:3, \"Bar\" = 5)) |>\n group_tt(j = list(\"Hello\" = 1:2, \"World\" = 4:5))\n\n \n\n \n \n \n tinytable_bm1pxjnqhb59o78up0dp\n \n \n \n \n \n\n \n \n \n \n\nHello\n \nWorld\n\n\n \nFoo\n \nBar\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -76,7 +76,7 @@
"href": "vignettes/group.html#rows",
"title": "Groups and labels",
"section": "",
- "text": "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:\n\ndat <- mtcars[1:9, 1:8]\n\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 tinytable_c8eiag9f6z1wg268mp8k\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\nThe numbers in the i list indicate that a label must be inserted at position # in the original table (without row groups). For example,\n\ntt(head(iris)) |>\n group_tt(i = list(\"After 1\" = 2, \"After 2\" = 3, \"After 3\" = 4, \"After 5\" = 6))\n\nWarning in `[<-.factor`(`*tmp*`, idx, value = \"\"): invalid factor level, NA\ngenerated\n\n\n \n\n \n \n \n tinytable_xmkgl3khin4u6kpjdf20\n \n \n \n \n \n\n \n \n \n \n \n \n Sepal.Length\n Sepal.Width\n Petal.Length\n Petal.Width\n Species\n \n \n \n \n \n 5.1\n 3.5\n 1.4\n 0.2\n setosa\n \n \n 4.9\n 3 \n 1.4\n 0.2\n setosa\n \n \n 4.7\n 3.2\n 1.3\n 0.2\n setosa\n \n \n 4.6\n 3.1\n 1.5\n 0.2\n setosa\n \n \n 5 \n 3.6\n 1.4\n 0.2\n setosa\n \n \n 5.4\n 3.9\n 1.7\n 0.4\n setosa\n \n \n \n \n\n \n\n \n\n\n\ntt(head(iris)) |>\n group_tt(i = list(\"After 1a\" = 2, \"After 1b\" = 2, \"After 5\" = 6))\n\nWarning in `[<-.factor`(`*tmp*`, idx, value = \"\"): invalid factor level, NA\ngenerated\n\n\n \n\n \n \n \n tinytable_5l6mnnbrbtjgbl0e4q3s\n \n \n \n \n \n\n \n \n \n \n \n \n Sepal.Length\n Sepal.Width\n Petal.Length\n Petal.Width\n Species\n \n \n \n \n \n 5.1\n 3.5\n 1.4\n 0.2\n setosa\n \n \n 4.9\n 3 \n 1.4\n 0.2\n setosa\n \n \n 4.7\n 3.2\n 1.3\n 0.2\n setosa\n \n \n 4.6\n 3.1\n 1.5\n 0.2\n setosa\n \n \n 5 \n 3.6\n 1.4\n 0.2\n setosa\n \n \n 5.4\n 3.9\n 1.7\n 0.4\n setosa\n \n \n \n \n\n \n\n \n\n\n\ntt(head(iris)) |>\n group_tt(i = list(\"After 0\" = 1))\n\nWarning in `[<-.factor`(`*tmp*`, idx, value = \"\"): invalid factor level, NA\ngenerated\n\n\n \n\n \n \n \n tinytable_6rd9an7purh509u5o04g\n \n \n \n \n \n\n \n \n \n \n \n \n Sepal.Length\n Sepal.Width\n Petal.Length\n Petal.Width\n Species\n \n \n \n \n \n 5.1\n 3.5\n 1.4\n 0.2\n setosa\n \n \n 4.9\n 3 \n 1.4\n 0.2\n setosa\n \n \n 4.7\n 3.2\n 1.3\n 0.2\n setosa\n \n \n 4.6\n 3.1\n 1.5\n 0.2\n setosa\n \n \n 5 \n 3.6\n 1.4\n 0.2\n setosa\n \n \n 5.4\n 3.9\n 1.7\n 0.4\n setosa\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style group rows in the same way as regular rows:\n\ntt(dat) |> \n group_tt(\n i = list(\n \"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7)) |>\n style_tt(\n i = c(3, 5, 9),\n align = \"c\",\n color = \"white\",\n background = \"gray\",\n bold = TRUE)\n\n \n\n \n \n \n tinytable_za6k80fvvaniwp9lgp93\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1",
+ "text": "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:\n\ndat <- mtcars[1:9, 1:8]\n\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 tinytable_xp60hoxwwisq7bno5twh\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\nThe numbers in the i list indicate that a label must be inserted at position # in the original table (without row groups). For example,\n\ntt(head(iris)) |>\n group_tt(i = list(\"After 1\" = 2, \"After 2\" = 3, \"After 3\" = 4, \"After 5\" = 6))\n\nWarning in `[<-.factor`(`*tmp*`, idx, value = \"\"): invalid factor level, NA\ngenerated\n\n\n \n\n \n \n \n tinytable_j6cqg0troahn9n70q2ry\n \n \n \n \n \n\n \n \n \n \n \n \n Sepal.Length\n Sepal.Width\n Petal.Length\n Petal.Width\n Species\n \n \n \n \n \n 5.1\n 3.5\n 1.4\n 0.2\n setosa\n \n \n 4.9\n 3 \n 1.4\n 0.2\n setosa\n \n \n 4.7\n 3.2\n 1.3\n 0.2\n setosa\n \n \n 4.6\n 3.1\n 1.5\n 0.2\n setosa\n \n \n 5 \n 3.6\n 1.4\n 0.2\n setosa\n \n \n 5.4\n 3.9\n 1.7\n 0.4\n setosa\n \n \n \n \n\n \n\n \n\n\n\ntt(head(iris)) |>\n group_tt(i = list(\"After 1a\" = 2, \"After 1b\" = 2, \"After 5\" = 6))\n\nWarning in `[<-.factor`(`*tmp*`, idx, value = \"\"): invalid factor level, NA\ngenerated\n\n\n \n\n \n \n \n tinytable_xzyf2iymg8uuojk41dat\n \n \n \n \n \n\n \n \n \n \n \n \n Sepal.Length\n Sepal.Width\n Petal.Length\n Petal.Width\n Species\n \n \n \n \n \n 5.1\n 3.5\n 1.4\n 0.2\n setosa\n \n \n 4.9\n 3 \n 1.4\n 0.2\n setosa\n \n \n 4.7\n 3.2\n 1.3\n 0.2\n setosa\n \n \n 4.6\n 3.1\n 1.5\n 0.2\n setosa\n \n \n 5 \n 3.6\n 1.4\n 0.2\n setosa\n \n \n 5.4\n 3.9\n 1.7\n 0.4\n setosa\n \n \n \n \n\n \n\n \n\n\n\ntt(head(iris)) |>\n group_tt(i = list(\"After 0\" = 1))\n\nWarning in `[<-.factor`(`*tmp*`, idx, value = \"\"): invalid factor level, NA\ngenerated\n\n\n \n\n \n \n \n tinytable_3ow0atlnpt0n80u3a52y\n \n \n \n \n \n\n \n \n \n \n \n \n Sepal.Length\n Sepal.Width\n Petal.Length\n Petal.Width\n Species\n \n \n \n \n \n 5.1\n 3.5\n 1.4\n 0.2\n setosa\n \n \n 4.9\n 3 \n 1.4\n 0.2\n setosa\n \n \n 4.7\n 3.2\n 1.3\n 0.2\n setosa\n \n \n 4.6\n 3.1\n 1.5\n 0.2\n setosa\n \n \n 5 \n 3.6\n 1.4\n 0.2\n setosa\n \n \n 5.4\n 3.9\n 1.7\n 0.4\n setosa\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style group rows in the same way as regular rows:\n\ntt(dat) |> \n group_tt(\n i = list(\n \"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7)) |>\n style_tt(\n i = c(3, 5, 9),\n align = \"c\",\n color = \"white\",\n background = \"gray\",\n bold = TRUE)\n\n \n\n \n \n \n tinytable_4pmjsj9e6h4vdsudp5t1\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -88,7 +88,7 @@
"href": "vignettes/group.html#columns",
"title": "Groups and labels",
"section": "",
- "text": "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:\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 tinytable_gz7cluhnpl32qkx8hml1\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\nHere is a table with both row and column headers, as well as some styling:\n\ndat <- mtcars[1:9, 1:8]\ntt(dat) |> \n group_tt(\n i = list(\"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7),\n j = list(\"Hamburgers\" = 1:3,\n \"Halloumi\" = 4:5,\n \"Tofu\" = 7)) |>\n style_tt(\n i = c(3, 5, 9),\n align = \"c\",\n background = \"teal\",\n color = \"white\") |>\n style_tt(i = -1, color = \"teal\")\n\n \n\n \n \n \n tinytable_mrjgast7cp2urtbo0raf\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also stack several extra headers on top of one another:\n\ntt(x) |>\n group_tt(j = list(\"Foo\" = 2:3, \"Bar\" = 5)) |>\n group_tt(j = list(\"Hello\" = 1:2, \"World\" = 4:5))\n\n \n\n \n \n \n tinytable_b2biib6yifsljysq0ufm\n \n \n \n \n \n\n \n \n \n \n\nHello\n \nWorld\n\n\n \nFoo\n \nBar\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
+ "text": "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:\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 tinytable_y38y7pfrcz175no7sxw6\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\nHere is a table with both row and column headers, as well as some styling:\n\ndat <- mtcars[1:9, 1:8]\ntt(dat) |> \n group_tt(\n i = list(\"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7),\n j = list(\"Hamburgers\" = 1:3,\n \"Halloumi\" = 4:5,\n \"Tofu\" = 7)) |>\n style_tt(\n i = c(3, 5, 9),\n align = \"c\",\n background = \"teal\",\n color = \"white\") |>\n style_tt(i = -1, color = \"teal\")\n\n \n\n \n \n \n tinytable_mj7jims8y5iblai8dwe8\n \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 \n 6\n 160\n 110\n 3.9 \n 2.62\n 16.5\n 0\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n 2.88\n 17 \n 0\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.32\n 18.6\n 1\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.21\n 19.4\n 1\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.44\n 17 \n 0\n \n \n 18.1\n 6\n 225\n 105\n 2.76\n 3.46\n 20.2\n 1\n \n \n 14.3\n 8\n 360\n 245\n 3.21\n 3.57\n 15.8\n 0\n \n \n 24.4\n 4\n 147\n 62\n 3.69\n 3.19\n 20 \n 1\n \n \n 22.8\n 4\n 141\n 95\n 3.92\n 3.15\n 22.9\n 1\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also stack several extra headers on top of one another:\n\ntt(x) |>\n group_tt(j = list(\"Foo\" = 2:3, \"Bar\" = 5)) |>\n group_tt(j = list(\"Hello\" = 1:2, \"World\" = 4:5))\n\n \n\n \n \n \n tinytable_bm1pxjnqhb59o78up0dp\n \n \n \n \n \n\n \n \n \n \n\nHello\n \nWorld\n\n\n \nFoo\n \nBar\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -148,7 +148,7 @@
"href": "CITATION.html",
"title": "Citation",
"section": "",
- "text": "Citation\nTo cite package ‘tinytable’ in publications use:\n\n Arel-Bundock V (????). _tinytable: Simple and Configurable Tables in\n 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', and 'Typst'\n Formats_. R package version 0.3.0.7,\n <https://vincentarelbundock.github.io/tinytable/>.\n\nA BibTeX entry for LaTeX users is\n\n @Manual{,\n title = {tinytable: Simple and Configurable Tables in 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', and 'Typst' Formats},\n author = {Vincent Arel-Bundock},\n note = {R package version 0.3.0.7},\n url = {https://vincentarelbundock.github.io/tinytable/},\n }",
+ "text": "Citation\nTo cite package ‘tinytable’ in publications use:\n\n Arel-Bundock V (????). _tinytable: Simple and Configurable Tables in\n 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', and 'Typst'\n Formats_. R package version 0.3.0.8,\n <https://vincentarelbundock.github.io/tinytable/>.\n\nA BibTeX entry for LaTeX users is\n\n @Manual{,\n title = {tinytable: Simple and Configurable Tables in 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', and 'Typst' Formats},\n author = {Vincent Arel-Bundock},\n note = {R package version 0.3.0.8},\n url = {https://vincentarelbundock.github.io/tinytable/},\n }",
"crumbs": [
"Tutorial (PDF)",
"Citation"
@@ -183,7 +183,7 @@
"href": "man/theme_tt.html",
"title": "tinytable",
"section": "",
- "text": "A theme is a function which applies a collection of transformations to a tinytable object. Whereas the other tinytable functions such as format_tt() and style_tt() aim to be output-agnostic, themes can be output-specific, only applying to LaTeX, HTML, or Typst, as needed.\nEach theme can have specific arguments, which are passed to the theme_tt() function. See the \"Arguments\" section below.\n\n\n\ntheme_tt(x, theme, ...)\n\n\n\n\n\n\n\nx\n\n\nA tinytable object\n\n\n\n\ntheme\n\n\nString. Name of the theme to apply. One of:\n\n\n\"grid\": Vertical and horizontal rules around each cell.\n\n\n\"void\": No rules\n\n\n\"bootstrap\": Similar appearance to the default Bootstrap theme in HTML\n\n\n\"striped\": Grey stripes on alternating rows\n\n\n\"tabular\": No table environment (LaTeX) or Javascript/CSS (HTML)\n\n\n\"resize\": Scale a LaTeX tinytable to fit the width argument.\n\n\n\"multipage\": Long tables continue on the next page (LaTeX only)\n\n\n\"placement\": Position of the table environment (LaTeX)\n\n\n\n\n\n\n…\n\n\nAdditional arguments passed the themeing function. See the \"Arguments\" section below for a list of supported arguments for each theme.\n\n\n\n\n\n\nA modified tinytable object\n\n\n\nresize\n\n\nwidth: A numeric value between 0.01 and 1, representing the proportion of the line width to use\n\n\ndirection: \"down\", \"up\", \"both\" A string indicating if the table should be scaled in one direction. For example, \"down\" will only resize the table if it exceeds \n\n\nmultipage\n\n\nrowhead: Non-negative integer. The number of header rows to repeat on each page.\n\n\nrowfoot: Non-negative integer. The number of footer rows to repeat on each page.\n\n\nplacement\n\n\nlatex_float: String to insert in square brackets after the LaTeX table environment, ex: \"H\", \"htbp\". The default value is controlled by a global option:\n\n\noptions(“tinytable_theme_placement_latex_float” = “H”)\n\n\n\n\n\n\n\n\nlibrary(tinytable)\n\nlibrary(tinytable)\n\nx <- mtcars[1:4, 1:4]\n\n# equivalent calls\ntt(x, theme = \"striped\")\n\n \n\n \n \n \n tinytable_jz7ym5bi2ruz8nvqi3nz\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n \n \n 21.0\n 6\n 160\n 110\n \n \n 22.8\n 4\n 108\n 93\n \n \n 21.4\n 6\n 258\n 110\n \n \n \n \n\n \n\n \n\n\n\ntt(x) |> theme_tt(\"striped\")\n\n \n\n \n \n \n tinytable_rotfp20hun7q28t1ad13\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n \n \n 21.0\n 6\n 160\n 110\n \n \n 22.8\n 4\n 108\n 93\n \n \n 21.4\n 6\n 258\n 110\n \n \n \n \n\n \n\n \n\n\n\n# resize w/ argument\nx <- cbind(mtcars[1:10,], mtcars[1:10,])\ntt(x) |>\n theme_tt(\"resize\", width = .9) |>\n print(\"latex\")\n\n\\begin{table}\n\\centering\n\\resizebox{\\ifdim\\width>\\linewidth 0.9\\linewidth\\else\\width\\fi}{!}{\n\\begin{tblr}[ %% tabularray outer open\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nmpg & cyl & disp & hp & drat & wt & qsec & vs & am & gear & carb & mpg & cyl & disp & hp & drat & wt & qsec & vs & am & gear & carb \\\\ \\midrule %% TinyTableHeader\n21.0 & 6 & 160.0 & 110 & 3.90 & 2.620 & 16.46 & 0 & 1 & 4 & 4 & 21.0 & 6 & 160.0 & 110 & 3.90 & 2.620 & 16.46 & 0 & 1 & 4 & 4 \\\\\n21.0 & 6 & 160.0 & 110 & 3.90 & 2.875 & 17.02 & 0 & 1 & 4 & 4 & 21.0 & 6 & 160.0 & 110 & 3.90 & 2.875 & 17.02 & 0 & 1 & 4 & 4 \\\\\n22.8 & 4 & 108.0 & 93 & 3.85 & 2.320 & 18.61 & 1 & 1 & 4 & 1 & 22.8 & 4 & 108.0 & 93 & 3.85 & 2.320 & 18.61 & 1 & 1 & 4 & 1 \\\\\n21.4 & 6 & 258.0 & 110 & 3.08 & 3.215 & 19.44 & 1 & 0 & 3 & 1 & 21.4 & 6 & 258.0 & 110 & 3.08 & 3.215 & 19.44 & 1 & 0 & 3 & 1 \\\\\n18.7 & 8 & 360.0 & 175 & 3.15 & 3.440 & 17.02 & 0 & 0 & 3 & 2 & 18.7 & 8 & 360.0 & 175 & 3.15 & 3.440 & 17.02 & 0 & 0 & 3 & 2 \\\\\n18.1 & 6 & 225.0 & 105 & 2.76 & 3.460 & 20.22 & 1 & 0 & 3 & 1 & 18.1 & 6 & 225.0 & 105 & 2.76 & 3.460 & 20.22 & 1 & 0 & 3 & 1 \\\\\n14.3 & 8 & 360.0 & 245 & 3.21 & 3.570 & 15.84 & 0 & 0 & 3 & 4 & 14.3 & 8 & 360.0 & 245 & 3.21 & 3.570 & 15.84 & 0 & 0 & 3 & 4 \\\\\n24.4 & 4 & 146.7 & 62 & 3.69 & 3.190 & 20.00 & 1 & 0 & 4 & 2 & 24.4 & 4 & 146.7 & 62 & 3.69 & 3.190 & 20.00 & 1 & 0 & 4 & 2 \\\\\n22.8 & 4 & 140.8 & 95 & 3.92 & 3.150 & 22.90 & 1 & 0 & 4 & 2 & 22.8 & 4 & 140.8 & 95 & 3.92 & 3.150 & 22.90 & 1 & 0 & 4 & 2 \\\\\n19.2 & 6 & 167.6 & 123 & 3.92 & 3.440 & 18.30 & 1 & 0 & 4 & 4 & 19.2 & 6 & 167.6 & 123 & 3.92 & 3.440 & 18.30 & 1 & 0 & 4 & 4 \\\\\n\\bottomrule\n\\end{tblr}\n}\n\\end{table}",
+ "text": "A theme is a function which applies a collection of transformations to a tinytable object. Whereas the other tinytable functions such as format_tt() and style_tt() aim to be output-agnostic, themes can be output-specific, only applying to LaTeX, HTML, or Typst, as needed.\nEach theme can have specific arguments, which are passed to the theme_tt() function. See the \"Arguments\" section below.\n\n\n\ntheme_tt(x, theme, ...)\n\n\n\n\n\n\n\nx\n\n\nA tinytable object\n\n\n\n\ntheme\n\n\nString. Name of the theme to apply. One of:\n\n\n\"grid\": Vertical and horizontal rules around each cell.\n\n\n\"void\": No rules\n\n\n\"bootstrap\": Similar appearance to the default Bootstrap theme in HTML\n\n\n\"striped\": Grey stripes on alternating rows\n\n\n\"tabular\": No table environment (LaTeX) or Javascript/CSS (HTML)\n\n\n\"resize\": Scale a LaTeX tinytable to fit the width argument.\n\n\n\"multipage\": Long tables continue on the next page (LaTeX only)\n\n\n\"placement\": Position of the table environment (LaTeX)\n\n\n\n\n\n\n…\n\n\nAdditional arguments passed the themeing function. See the \"Arguments\" section below for a list of supported arguments for each theme.\n\n\n\n\n\n\nA modified tinytable object\n\n\n\nresize\n\n\nwidth: A numeric value between 0.01 and 1, representing the proportion of the line width to use\n\n\ndirection: \"down\", \"up\", \"both\" A string indicating if the table should be scaled in one direction. For example, \"down\" will only resize the table if it exceeds \n\n\nmultipage\n\n\nrowhead: Non-negative integer. The number of header rows to repeat on each page.\n\n\nrowfoot: Non-negative integer. The number of footer rows to repeat on each page.\n\n\nplacement\n\n\nlatex_float: String to insert in square brackets after the LaTeX table environment, ex: \"H\", \"htbp\". The default value is controlled by a global option:\n\n\noptions(“tinytable_theme_placement_latex_float” = “H”)\n\n\n\n\n\n\n\n\nlibrary(tinytable)\n\nlibrary(tinytable)\n\nx <- mtcars[1:4, 1:4]\n\n# equivalent calls\ntt(x, theme = \"striped\")\n\n \n\n \n \n \n tinytable_0jhl9x1039iawivnq4fo\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n \n \n 21.0\n 6\n 160\n 110\n \n \n 22.8\n 4\n 108\n 93\n \n \n 21.4\n 6\n 258\n 110\n \n \n \n \n\n \n\n \n\n\n\ntt(x) |> theme_tt(\"striped\")\n\n \n\n \n \n \n tinytable_s79lewb31x2me23bojc1\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n \n \n 21.0\n 6\n 160\n 110\n \n \n 22.8\n 4\n 108\n 93\n \n \n 21.4\n 6\n 258\n 110\n \n \n \n \n\n \n\n \n\n\n\n# resize w/ argument\nx <- cbind(mtcars[1:10,], mtcars[1:10,])\ntt(x) |>\n theme_tt(\"resize\", width = .9) |>\n print(\"latex\")\n\n\\begin{table}\n\\centering\n\\resizebox{\\ifdim\\width>\\linewidth 0.9\\linewidth\\else\\width\\fi}{!}{\n\\begin{tblr}[ %% tabularray outer open\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nmpg & cyl & disp & hp & drat & wt & qsec & vs & am & gear & carb & mpg & cyl & disp & hp & drat & wt & qsec & vs & am & gear & carb \\\\ \\midrule %% TinyTableHeader\n21.0 & 6 & 160.0 & 110 & 3.90 & 2.620 & 16.46 & 0 & 1 & 4 & 4 & 21.0 & 6 & 160.0 & 110 & 3.90 & 2.620 & 16.46 & 0 & 1 & 4 & 4 \\\\\n21.0 & 6 & 160.0 & 110 & 3.90 & 2.875 & 17.02 & 0 & 1 & 4 & 4 & 21.0 & 6 & 160.0 & 110 & 3.90 & 2.875 & 17.02 & 0 & 1 & 4 & 4 \\\\\n22.8 & 4 & 108.0 & 93 & 3.85 & 2.320 & 18.61 & 1 & 1 & 4 & 1 & 22.8 & 4 & 108.0 & 93 & 3.85 & 2.320 & 18.61 & 1 & 1 & 4 & 1 \\\\\n21.4 & 6 & 258.0 & 110 & 3.08 & 3.215 & 19.44 & 1 & 0 & 3 & 1 & 21.4 & 6 & 258.0 & 110 & 3.08 & 3.215 & 19.44 & 1 & 0 & 3 & 1 \\\\\n18.7 & 8 & 360.0 & 175 & 3.15 & 3.440 & 17.02 & 0 & 0 & 3 & 2 & 18.7 & 8 & 360.0 & 175 & 3.15 & 3.440 & 17.02 & 0 & 0 & 3 & 2 \\\\\n18.1 & 6 & 225.0 & 105 & 2.76 & 3.460 & 20.22 & 1 & 0 & 3 & 1 & 18.1 & 6 & 225.0 & 105 & 2.76 & 3.460 & 20.22 & 1 & 0 & 3 & 1 \\\\\n14.3 & 8 & 360.0 & 245 & 3.21 & 3.570 & 15.84 & 0 & 0 & 3 & 4 & 14.3 & 8 & 360.0 & 245 & 3.21 & 3.570 & 15.84 & 0 & 0 & 3 & 4 \\\\\n24.4 & 4 & 146.7 & 62 & 3.69 & 3.190 & 20.00 & 1 & 0 & 4 & 2 & 24.4 & 4 & 146.7 & 62 & 3.69 & 3.190 & 20.00 & 1 & 0 & 4 & 2 \\\\\n22.8 & 4 & 140.8 & 95 & 3.92 & 3.150 & 22.90 & 1 & 0 & 4 & 2 & 22.8 & 4 & 140.8 & 95 & 3.92 & 3.150 & 22.90 & 1 & 0 & 4 & 2 \\\\\n19.2 & 6 & 167.6 & 123 & 3.92 & 3.440 & 18.30 & 1 & 0 & 4 & 4 & 19.2 & 6 & 167.6 & 123 & 3.92 & 3.440 & 18.30 & 1 & 0 & 4 & 4 \\\\\n\\bottomrule\n\\end{tblr}\n}\n\\end{table}",
"crumbs": [
"Tutorial (PDF)",
"Functions",
@@ -195,7 +195,7 @@
"href": "man/theme_tt.html#themes-for-tinytable",
"title": "tinytable",
"section": "",
- "text": "A theme is a function which applies a collection of transformations to a tinytable object. Whereas the other tinytable functions such as format_tt() and style_tt() aim to be output-agnostic, themes can be output-specific, only applying to LaTeX, HTML, or Typst, as needed.\nEach theme can have specific arguments, which are passed to the theme_tt() function. See the \"Arguments\" section below.\n\n\n\ntheme_tt(x, theme, ...)\n\n\n\n\n\n\n\nx\n\n\nA tinytable object\n\n\n\n\ntheme\n\n\nString. Name of the theme to apply. One of:\n\n\n\"grid\": Vertical and horizontal rules around each cell.\n\n\n\"void\": No rules\n\n\n\"bootstrap\": Similar appearance to the default Bootstrap theme in HTML\n\n\n\"striped\": Grey stripes on alternating rows\n\n\n\"tabular\": No table environment (LaTeX) or Javascript/CSS (HTML)\n\n\n\"resize\": Scale a LaTeX tinytable to fit the width argument.\n\n\n\"multipage\": Long tables continue on the next page (LaTeX only)\n\n\n\"placement\": Position of the table environment (LaTeX)\n\n\n\n\n\n\n…\n\n\nAdditional arguments passed the themeing function. See the \"Arguments\" section below for a list of supported arguments for each theme.\n\n\n\n\n\n\nA modified tinytable object\n\n\n\nresize\n\n\nwidth: A numeric value between 0.01 and 1, representing the proportion of the line width to use\n\n\ndirection: \"down\", \"up\", \"both\" A string indicating if the table should be scaled in one direction. For example, \"down\" will only resize the table if it exceeds \n\n\nmultipage\n\n\nrowhead: Non-negative integer. The number of header rows to repeat on each page.\n\n\nrowfoot: Non-negative integer. The number of footer rows to repeat on each page.\n\n\nplacement\n\n\nlatex_float: String to insert in square brackets after the LaTeX table environment, ex: \"H\", \"htbp\". The default value is controlled by a global option:\n\n\noptions(“tinytable_theme_placement_latex_float” = “H”)\n\n\n\n\n\n\n\n\nlibrary(tinytable)\n\nlibrary(tinytable)\n\nx <- mtcars[1:4, 1:4]\n\n# equivalent calls\ntt(x, theme = \"striped\")\n\n \n\n \n \n \n tinytable_jz7ym5bi2ruz8nvqi3nz\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n \n \n 21.0\n 6\n 160\n 110\n \n \n 22.8\n 4\n 108\n 93\n \n \n 21.4\n 6\n 258\n 110\n \n \n \n \n\n \n\n \n\n\n\ntt(x) |> theme_tt(\"striped\")\n\n \n\n \n \n \n tinytable_rotfp20hun7q28t1ad13\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n \n \n 21.0\n 6\n 160\n 110\n \n \n 22.8\n 4\n 108\n 93\n \n \n 21.4\n 6\n 258\n 110\n \n \n \n \n\n \n\n \n\n\n\n# resize w/ argument\nx <- cbind(mtcars[1:10,], mtcars[1:10,])\ntt(x) |>\n theme_tt(\"resize\", width = .9) |>\n print(\"latex\")\n\n\\begin{table}\n\\centering\n\\resizebox{\\ifdim\\width>\\linewidth 0.9\\linewidth\\else\\width\\fi}{!}{\n\\begin{tblr}[ %% tabularray outer open\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nmpg & cyl & disp & hp & drat & wt & qsec & vs & am & gear & carb & mpg & cyl & disp & hp & drat & wt & qsec & vs & am & gear & carb \\\\ \\midrule %% TinyTableHeader\n21.0 & 6 & 160.0 & 110 & 3.90 & 2.620 & 16.46 & 0 & 1 & 4 & 4 & 21.0 & 6 & 160.0 & 110 & 3.90 & 2.620 & 16.46 & 0 & 1 & 4 & 4 \\\\\n21.0 & 6 & 160.0 & 110 & 3.90 & 2.875 & 17.02 & 0 & 1 & 4 & 4 & 21.0 & 6 & 160.0 & 110 & 3.90 & 2.875 & 17.02 & 0 & 1 & 4 & 4 \\\\\n22.8 & 4 & 108.0 & 93 & 3.85 & 2.320 & 18.61 & 1 & 1 & 4 & 1 & 22.8 & 4 & 108.0 & 93 & 3.85 & 2.320 & 18.61 & 1 & 1 & 4 & 1 \\\\\n21.4 & 6 & 258.0 & 110 & 3.08 & 3.215 & 19.44 & 1 & 0 & 3 & 1 & 21.4 & 6 & 258.0 & 110 & 3.08 & 3.215 & 19.44 & 1 & 0 & 3 & 1 \\\\\n18.7 & 8 & 360.0 & 175 & 3.15 & 3.440 & 17.02 & 0 & 0 & 3 & 2 & 18.7 & 8 & 360.0 & 175 & 3.15 & 3.440 & 17.02 & 0 & 0 & 3 & 2 \\\\\n18.1 & 6 & 225.0 & 105 & 2.76 & 3.460 & 20.22 & 1 & 0 & 3 & 1 & 18.1 & 6 & 225.0 & 105 & 2.76 & 3.460 & 20.22 & 1 & 0 & 3 & 1 \\\\\n14.3 & 8 & 360.0 & 245 & 3.21 & 3.570 & 15.84 & 0 & 0 & 3 & 4 & 14.3 & 8 & 360.0 & 245 & 3.21 & 3.570 & 15.84 & 0 & 0 & 3 & 4 \\\\\n24.4 & 4 & 146.7 & 62 & 3.69 & 3.190 & 20.00 & 1 & 0 & 4 & 2 & 24.4 & 4 & 146.7 & 62 & 3.69 & 3.190 & 20.00 & 1 & 0 & 4 & 2 \\\\\n22.8 & 4 & 140.8 & 95 & 3.92 & 3.150 & 22.90 & 1 & 0 & 4 & 2 & 22.8 & 4 & 140.8 & 95 & 3.92 & 3.150 & 22.90 & 1 & 0 & 4 & 2 \\\\\n19.2 & 6 & 167.6 & 123 & 3.92 & 3.440 & 18.30 & 1 & 0 & 4 & 4 & 19.2 & 6 & 167.6 & 123 & 3.92 & 3.440 & 18.30 & 1 & 0 & 4 & 4 \\\\\n\\bottomrule\n\\end{tblr}\n}\n\\end{table}",
+ "text": "A theme is a function which applies a collection of transformations to a tinytable object. Whereas the other tinytable functions such as format_tt() and style_tt() aim to be output-agnostic, themes can be output-specific, only applying to LaTeX, HTML, or Typst, as needed.\nEach theme can have specific arguments, which are passed to the theme_tt() function. See the \"Arguments\" section below.\n\n\n\ntheme_tt(x, theme, ...)\n\n\n\n\n\n\n\nx\n\n\nA tinytable object\n\n\n\n\ntheme\n\n\nString. Name of the theme to apply. One of:\n\n\n\"grid\": Vertical and horizontal rules around each cell.\n\n\n\"void\": No rules\n\n\n\"bootstrap\": Similar appearance to the default Bootstrap theme in HTML\n\n\n\"striped\": Grey stripes on alternating rows\n\n\n\"tabular\": No table environment (LaTeX) or Javascript/CSS (HTML)\n\n\n\"resize\": Scale a LaTeX tinytable to fit the width argument.\n\n\n\"multipage\": Long tables continue on the next page (LaTeX only)\n\n\n\"placement\": Position of the table environment (LaTeX)\n\n\n\n\n\n\n…\n\n\nAdditional arguments passed the themeing function. See the \"Arguments\" section below for a list of supported arguments for each theme.\n\n\n\n\n\n\nA modified tinytable object\n\n\n\nresize\n\n\nwidth: A numeric value between 0.01 and 1, representing the proportion of the line width to use\n\n\ndirection: \"down\", \"up\", \"both\" A string indicating if the table should be scaled in one direction. For example, \"down\" will only resize the table if it exceeds \n\n\nmultipage\n\n\nrowhead: Non-negative integer. The number of header rows to repeat on each page.\n\n\nrowfoot: Non-negative integer. The number of footer rows to repeat on each page.\n\n\nplacement\n\n\nlatex_float: String to insert in square brackets after the LaTeX table environment, ex: \"H\", \"htbp\". The default value is controlled by a global option:\n\n\noptions(“tinytable_theme_placement_latex_float” = “H”)\n\n\n\n\n\n\n\n\nlibrary(tinytable)\n\nlibrary(tinytable)\n\nx <- mtcars[1:4, 1:4]\n\n# equivalent calls\ntt(x, theme = \"striped\")\n\n \n\n \n \n \n tinytable_0jhl9x1039iawivnq4fo\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n \n \n 21.0\n 6\n 160\n 110\n \n \n 22.8\n 4\n 108\n 93\n \n \n 21.4\n 6\n 258\n 110\n \n \n \n \n\n \n\n \n\n\n\ntt(x) |> theme_tt(\"striped\")\n\n \n\n \n \n \n tinytable_s79lewb31x2me23bojc1\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n \n \n 21.0\n 6\n 160\n 110\n \n \n 22.8\n 4\n 108\n 93\n \n \n 21.4\n 6\n 258\n 110\n \n \n \n \n\n \n\n \n\n\n\n# resize w/ argument\nx <- cbind(mtcars[1:10,], mtcars[1:10,])\ntt(x) |>\n theme_tt(\"resize\", width = .9) |>\n print(\"latex\")\n\n\\begin{table}\n\\centering\n\\resizebox{\\ifdim\\width>\\linewidth 0.9\\linewidth\\else\\width\\fi}{!}{\n\\begin{tblr}[ %% tabularray outer open\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nmpg & cyl & disp & hp & drat & wt & qsec & vs & am & gear & carb & mpg & cyl & disp & hp & drat & wt & qsec & vs & am & gear & carb \\\\ \\midrule %% TinyTableHeader\n21.0 & 6 & 160.0 & 110 & 3.90 & 2.620 & 16.46 & 0 & 1 & 4 & 4 & 21.0 & 6 & 160.0 & 110 & 3.90 & 2.620 & 16.46 & 0 & 1 & 4 & 4 \\\\\n21.0 & 6 & 160.0 & 110 & 3.90 & 2.875 & 17.02 & 0 & 1 & 4 & 4 & 21.0 & 6 & 160.0 & 110 & 3.90 & 2.875 & 17.02 & 0 & 1 & 4 & 4 \\\\\n22.8 & 4 & 108.0 & 93 & 3.85 & 2.320 & 18.61 & 1 & 1 & 4 & 1 & 22.8 & 4 & 108.0 & 93 & 3.85 & 2.320 & 18.61 & 1 & 1 & 4 & 1 \\\\\n21.4 & 6 & 258.0 & 110 & 3.08 & 3.215 & 19.44 & 1 & 0 & 3 & 1 & 21.4 & 6 & 258.0 & 110 & 3.08 & 3.215 & 19.44 & 1 & 0 & 3 & 1 \\\\\n18.7 & 8 & 360.0 & 175 & 3.15 & 3.440 & 17.02 & 0 & 0 & 3 & 2 & 18.7 & 8 & 360.0 & 175 & 3.15 & 3.440 & 17.02 & 0 & 0 & 3 & 2 \\\\\n18.1 & 6 & 225.0 & 105 & 2.76 & 3.460 & 20.22 & 1 & 0 & 3 & 1 & 18.1 & 6 & 225.0 & 105 & 2.76 & 3.460 & 20.22 & 1 & 0 & 3 & 1 \\\\\n14.3 & 8 & 360.0 & 245 & 3.21 & 3.570 & 15.84 & 0 & 0 & 3 & 4 & 14.3 & 8 & 360.0 & 245 & 3.21 & 3.570 & 15.84 & 0 & 0 & 3 & 4 \\\\\n24.4 & 4 & 146.7 & 62 & 3.69 & 3.190 & 20.00 & 1 & 0 & 4 & 2 & 24.4 & 4 & 146.7 & 62 & 3.69 & 3.190 & 20.00 & 1 & 0 & 4 & 2 \\\\\n22.8 & 4 & 140.8 & 95 & 3.92 & 3.150 & 22.90 & 1 & 0 & 4 & 2 & 22.8 & 4 & 140.8 & 95 & 3.92 & 3.150 & 22.90 & 1 & 0 & 4 & 2 \\\\\n19.2 & 6 & 167.6 & 123 & 3.92 & 3.440 & 18.30 & 1 & 0 & 4 & 4 & 19.2 & 6 & 167.6 & 123 & 3.92 & 3.440 & 18.30 & 1 & 0 & 4 & 4 \\\\\n\\bottomrule\n\\end{tblr}\n}\n\\end{table}",
"crumbs": [
"Tutorial (PDF)",
"Functions",
@@ -207,7 +207,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 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\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 tinytable_fxc97k767y6mtccgegdw\n \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 \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 tinytable_vkamaf3u0jjlr1nsm1oa\n \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 \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 tinytable_1n38lzwkkpevwddc624g\n \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 \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 tinytable_hp07p2bzeom5a2iui8fd\n \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 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\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 tinytable_0qhd6tjiceh9ryy73qwn\n \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 \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 tinytable_xhvoeupi21m10t1qrps1\n \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 \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 tinytable_451cd351owzmggefww6x\n \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 \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 tinytable_jcsg566npcajfybupaus\n \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",
@@ -219,7 +219,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 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\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 tinytable_fxc97k767y6mtccgegdw\n \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 \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 tinytable_vkamaf3u0jjlr1nsm1oa\n \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 \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 tinytable_1n38lzwkkpevwddc624g\n \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 \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 tinytable_hp07p2bzeom5a2iui8fd\n \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 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\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 tinytable_0qhd6tjiceh9ryy73qwn\n \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 \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 tinytable_xhvoeupi21m10t1qrps1\n \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 \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 tinytable_451cd351owzmggefww6x\n \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 \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 tinytable_jcsg566npcajfybupaus\n \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",
@@ -255,7 +255,7 @@
"href": "man/rbind2-tinytable-tinytable-method.html",
"title": "tinytable",
"section": "",
- "text": "Combine tinytable objects by rows (vertically)\n\n\n\n## S4 method for signature 'tinytable,tinytable'\nrbind2(x, y, use_names = TRUE, headers = TRUE, ...)\n\n\n\n\n\n\n\nx\n\n\ntinytable object\n\n\n\n\ny\n\n\ntinytable object\n\n\n\n\nuse_names\n\n\n‘TRUE’ binds by matching column name, ‘FALSE’ by position\n\n\n\n\nheaders\n\n\nLogical. TRUE inserts the colnames of y as an extra row between the two tables.\n\n\n\n\n…\n\n\nAdditional arguments are ignored.\n\n\n\n\n\n\nformat_tt() calls applied to x or y are evaluated before binding, to allow distinct formatting for each panel.\nCalls to other tinytable functions such as style_tt() or group_tt() are ignored when applied to x or y. These functions should be applied to the final table instead.\nInformation in these S4 slots is carried over from x to the combined table:\n\n\nx@output\n\n\nx@caption\n\n\nx@width\n\n\nInformation in these S4 slots is concatenated and carried over to the combined table:\n\n\nc(x@notes, y@notes)\n\n\nThis function relies on the rbindlist() function from the data.table package.\n\n\n\n\nlibrary(tinytable)\n\nlibrary(tinytable)\nx = tt(mtcars[1:3, 1:2], caption = \"Combine two tiny tables.\")\ny = tt(mtcars[4:5, 8:10]) \n\n# rbind() does not support additional aarguments\n# rbind2() supports additional arguments\n\n# basic combination\nrbind(x, y)\n\n \n\n \n \n \n tinytable_0io1f4ab32wwqvlf6qs5\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21.0\n 6 \n NA\n NA\n NA \n \n \n 21.0\n 6 \n NA\n NA\n NA \n \n \n 22.8\n 4 \n NA\n NA\n NA \n \n \n NA \n NA\n vs\n am\n gear\n \n \n NA \n NA\n 1 \n 0 \n 3 \n \n \n NA \n NA\n 0 \n 0 \n 3 \n \n \n \n \n\n \n\n \n\n\n\nrbind(x, y) |> format_tt(replace = \"\")\n\n \n\n \n \n \n tinytable_qg6xcgvkth15bvt0jlv0\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21.0\n 6\n \n \n \n \n \n 21.0\n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n vs\n am\n gear\n \n \n \n \n 1\n 0\n 3\n \n \n \n \n 0\n 0\n 3\n \n \n \n \n\n \n\n \n\n\n\n# omit y header\nrbind2(x, y, headers = FALSE)\n\n \n\n \n \n \n tinytable_awb1n9cwtb15qfnfxloy\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21.0\n 6 \n NA\n NA\n NA\n \n \n 21.0\n 6 \n NA\n NA\n NA\n \n \n 22.8\n 4 \n NA\n NA\n NA\n \n \n NA \n NA\n 1 \n 0 \n 3 \n \n \n NA \n NA\n 0 \n 0 \n 3 \n \n \n \n \n\n \n\n \n\n\n\n# bind by position rather than column names\nrbind2(x, y, use_names = FALSE)\n\n \n\n \n \n \n tinytable_rqdcdu4helgpe0vfkrjv\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n gear\n \n \n \n \n \n 21.0\n 6 \n NA \n \n \n 21.0\n 6 \n NA \n \n \n 22.8\n 4 \n NA \n \n \n vs \n am\n gear\n \n \n 1 \n 0 \n 3 \n \n \n 0 \n 0 \n 3",
+ "text": "Combine tinytable objects by rows (vertically)\n\n\n\n## S4 method for signature 'tinytable,tinytable'\nrbind2(x, y, use_names = TRUE, headers = TRUE, ...)\n\n\n\n\n\n\n\nx\n\n\ntinytable object\n\n\n\n\ny\n\n\ntinytable object\n\n\n\n\nuse_names\n\n\n‘TRUE’ binds by matching column name, ‘FALSE’ by position\n\n\n\n\nheaders\n\n\nLogical. TRUE inserts the colnames of y as an extra row between the two tables.\n\n\n\n\n…\n\n\nAdditional arguments are ignored.\n\n\n\n\n\n\nformat_tt() calls applied to x or y are evaluated before binding, to allow distinct formatting for each panel.\nCalls to other tinytable functions such as style_tt() or group_tt() are ignored when applied to x or y. These functions should be applied to the final table instead.\nInformation in these S4 slots is carried over from x to the combined table:\n\n\nx@output\n\n\nx@caption\n\n\nx@width\n\n\nInformation in these S4 slots is concatenated and carried over to the combined table:\n\n\nc(x@notes, y@notes)\n\n\nThis function relies on the rbindlist() function from the data.table package.\n\n\n\n\nlibrary(tinytable)\n\nlibrary(tinytable)\nx = tt(mtcars[1:3, 1:2], caption = \"Combine two tiny tables.\")\ny = tt(mtcars[4:5, 8:10]) \n\n# rbind() does not support additional aarguments\n# rbind2() supports additional arguments\n\n# basic combination\nrbind(x, y)\n\n \n\n \n \n \n tinytable_7hcagka06xptowqmx249\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21.0\n 6 \n NA\n NA\n NA \n \n \n 21.0\n 6 \n NA\n NA\n NA \n \n \n 22.8\n 4 \n NA\n NA\n NA \n \n \n NA \n NA\n vs\n am\n gear\n \n \n NA \n NA\n 1 \n 0 \n 3 \n \n \n NA \n NA\n 0 \n 0 \n 3 \n \n \n \n \n\n \n\n \n\n\n\nrbind(x, y) |> format_tt(replace = \"\")\n\n \n\n \n \n \n tinytable_gv3lctrjm62uon6ol2po\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21.0\n 6\n \n \n \n \n \n 21.0\n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n vs\n am\n gear\n \n \n \n \n 1\n 0\n 3\n \n \n \n \n 0\n 0\n 3\n \n \n \n \n\n \n\n \n\n\n\n# omit y header\nrbind2(x, y, headers = FALSE)\n\n \n\n \n \n \n tinytable_vvyihltengei44kjvz27\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21.0\n 6 \n NA\n NA\n NA\n \n \n 21.0\n 6 \n NA\n NA\n NA\n \n \n 22.8\n 4 \n NA\n NA\n NA\n \n \n NA \n NA\n 1 \n 0 \n 3 \n \n \n NA \n NA\n 0 \n 0 \n 3 \n \n \n \n \n\n \n\n \n\n\n\n# bind by position rather than column names\nrbind2(x, y, use_names = FALSE)\n\n \n\n \n \n \n tinytable_r4zjkbkilbv41g5a5uo6\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n gear\n \n \n \n \n \n 21.0\n 6 \n NA \n \n \n 21.0\n 6 \n NA \n \n \n 22.8\n 4 \n NA \n \n \n vs \n am\n gear\n \n \n 1 \n 0 \n 3 \n \n \n 0 \n 0 \n 3",
"crumbs": [
"Tutorial (PDF)",
"Functions",
@@ -267,7 +267,7 @@
"href": "man/rbind2-tinytable-tinytable-method.html#combine-tinytable-objects-by-rows-vertically",
"title": "tinytable",
"section": "",
- "text": "Combine tinytable objects by rows (vertically)\n\n\n\n## S4 method for signature 'tinytable,tinytable'\nrbind2(x, y, use_names = TRUE, headers = TRUE, ...)\n\n\n\n\n\n\n\nx\n\n\ntinytable object\n\n\n\n\ny\n\n\ntinytable object\n\n\n\n\nuse_names\n\n\n‘TRUE’ binds by matching column name, ‘FALSE’ by position\n\n\n\n\nheaders\n\n\nLogical. TRUE inserts the colnames of y as an extra row between the two tables.\n\n\n\n\n…\n\n\nAdditional arguments are ignored.\n\n\n\n\n\n\nformat_tt() calls applied to x or y are evaluated before binding, to allow distinct formatting for each panel.\nCalls to other tinytable functions such as style_tt() or group_tt() are ignored when applied to x or y. These functions should be applied to the final table instead.\nInformation in these S4 slots is carried over from x to the combined table:\n\n\nx@output\n\n\nx@caption\n\n\nx@width\n\n\nInformation in these S4 slots is concatenated and carried over to the combined table:\n\n\nc(x@notes, y@notes)\n\n\nThis function relies on the rbindlist() function from the data.table package.\n\n\n\n\nlibrary(tinytable)\n\nlibrary(tinytable)\nx = tt(mtcars[1:3, 1:2], caption = \"Combine two tiny tables.\")\ny = tt(mtcars[4:5, 8:10]) \n\n# rbind() does not support additional aarguments\n# rbind2() supports additional arguments\n\n# basic combination\nrbind(x, y)\n\n \n\n \n \n \n tinytable_0io1f4ab32wwqvlf6qs5\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21.0\n 6 \n NA\n NA\n NA \n \n \n 21.0\n 6 \n NA\n NA\n NA \n \n \n 22.8\n 4 \n NA\n NA\n NA \n \n \n NA \n NA\n vs\n am\n gear\n \n \n NA \n NA\n 1 \n 0 \n 3 \n \n \n NA \n NA\n 0 \n 0 \n 3 \n \n \n \n \n\n \n\n \n\n\n\nrbind(x, y) |> format_tt(replace = \"\")\n\n \n\n \n \n \n tinytable_qg6xcgvkth15bvt0jlv0\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21.0\n 6\n \n \n \n \n \n 21.0\n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n vs\n am\n gear\n \n \n \n \n 1\n 0\n 3\n \n \n \n \n 0\n 0\n 3\n \n \n \n \n\n \n\n \n\n\n\n# omit y header\nrbind2(x, y, headers = FALSE)\n\n \n\n \n \n \n tinytable_awb1n9cwtb15qfnfxloy\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21.0\n 6 \n NA\n NA\n NA\n \n \n 21.0\n 6 \n NA\n NA\n NA\n \n \n 22.8\n 4 \n NA\n NA\n NA\n \n \n NA \n NA\n 1 \n 0 \n 3 \n \n \n NA \n NA\n 0 \n 0 \n 3 \n \n \n \n \n\n \n\n \n\n\n\n# bind by position rather than column names\nrbind2(x, y, use_names = FALSE)\n\n \n\n \n \n \n tinytable_rqdcdu4helgpe0vfkrjv\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n gear\n \n \n \n \n \n 21.0\n 6 \n NA \n \n \n 21.0\n 6 \n NA \n \n \n 22.8\n 4 \n NA \n \n \n vs \n am\n gear\n \n \n 1 \n 0 \n 3 \n \n \n 0 \n 0 \n 3",
+ "text": "Combine tinytable objects by rows (vertically)\n\n\n\n## S4 method for signature 'tinytable,tinytable'\nrbind2(x, y, use_names = TRUE, headers = TRUE, ...)\n\n\n\n\n\n\n\nx\n\n\ntinytable object\n\n\n\n\ny\n\n\ntinytable object\n\n\n\n\nuse_names\n\n\n‘TRUE’ binds by matching column name, ‘FALSE’ by position\n\n\n\n\nheaders\n\n\nLogical. TRUE inserts the colnames of y as an extra row between the two tables.\n\n\n\n\n…\n\n\nAdditional arguments are ignored.\n\n\n\n\n\n\nformat_tt() calls applied to x or y are evaluated before binding, to allow distinct formatting for each panel.\nCalls to other tinytable functions such as style_tt() or group_tt() are ignored when applied to x or y. These functions should be applied to the final table instead.\nInformation in these S4 slots is carried over from x to the combined table:\n\n\nx@output\n\n\nx@caption\n\n\nx@width\n\n\nInformation in these S4 slots is concatenated and carried over to the combined table:\n\n\nc(x@notes, y@notes)\n\n\nThis function relies on the rbindlist() function from the data.table package.\n\n\n\n\nlibrary(tinytable)\n\nlibrary(tinytable)\nx = tt(mtcars[1:3, 1:2], caption = \"Combine two tiny tables.\")\ny = tt(mtcars[4:5, 8:10]) \n\n# rbind() does not support additional aarguments\n# rbind2() supports additional arguments\n\n# basic combination\nrbind(x, y)\n\n \n\n \n \n \n tinytable_7hcagka06xptowqmx249\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21.0\n 6 \n NA\n NA\n NA \n \n \n 21.0\n 6 \n NA\n NA\n NA \n \n \n 22.8\n 4 \n NA\n NA\n NA \n \n \n NA \n NA\n vs\n am\n gear\n \n \n NA \n NA\n 1 \n 0 \n 3 \n \n \n NA \n NA\n 0 \n 0 \n 3 \n \n \n \n \n\n \n\n \n\n\n\nrbind(x, y) |> format_tt(replace = \"\")\n\n \n\n \n \n \n tinytable_gv3lctrjm62uon6ol2po\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21.0\n 6\n \n \n \n \n \n 21.0\n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n vs\n am\n gear\n \n \n \n \n 1\n 0\n 3\n \n \n \n \n 0\n 0\n 3\n \n \n \n \n\n \n\n \n\n\n\n# omit y header\nrbind2(x, y, headers = FALSE)\n\n \n\n \n \n \n tinytable_vvyihltengei44kjvz27\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21.0\n 6 \n NA\n NA\n NA\n \n \n 21.0\n 6 \n NA\n NA\n NA\n \n \n 22.8\n 4 \n NA\n NA\n NA\n \n \n NA \n NA\n 1 \n 0 \n 3 \n \n \n NA \n NA\n 0 \n 0 \n 3 \n \n \n \n \n\n \n\n \n\n\n\n# bind by position rather than column names\nrbind2(x, y, use_names = FALSE)\n\n \n\n \n \n \n tinytable_r4zjkbkilbv41g5a5uo6\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n gear\n \n \n \n \n \n 21.0\n 6 \n NA \n \n \n 21.0\n 6 \n NA \n \n \n 22.8\n 4 \n NA \n \n \n vs \n am\n gear\n \n \n 1 \n 0 \n 3 \n \n \n 0 \n 0 \n 3",
"crumbs": [
"Tutorial (PDF)",
"Functions",
@@ -307,7 +307,7 @@
"href": "index.html#tutorial",
"title": "tinytable",
"section": "Tutorial",
- "text": "Tutorial\nThe tinytable 0.3.0.7 tutorial will take you much further. It is available in two formats:\n\nTutorial (PDF)\nTutorial (HTML):\n\nTiny tables\nFormat\nStyle\nGroup labels\nPlots and images\nThemes\nCustomization\nFAQ\nAlternatives"
+ "text": "Tutorial\nThe tinytable 0.3.0.8 tutorial will take you much further. It is available in two formats:\n\nTutorial (PDF)\nTutorial (HTML):\n\nTiny tables\nFormat\nStyle\nGroup labels\nPlots and images\nThemes\nCustomization\nFAQ\nAlternatives"
},
{
"objectID": "index.html#footnotes",
@@ -321,7 +321,7 @@
"href": "NEWS.html",
"title": "News",
"section": "",
- "text": "Headers are now styled and formatted when i=NULL.\ncolnames(x)<-NULL works on a tinytable object.\nformat_tt(num_big_mark) applies to integer columns.\nPrint row names in the first column by calling options(tinytable_tt_rownames=TRUE). Thanks to @rsbivand for Issue #264.\nImproved documentation.\n\nBugs:\n\nreplace does not work in LaTeX with format_tt(quarto=TRUE). Thanks to @cbgoodman for Issue #263.\nstyle_tt(indent) works for LaTeX\n\n\n\n\nBreaking change:\n\nThe width argument is moved from style_tt() to tt().\n\ntt():\n\nwidth argument now accepts a vector of numeric values to control the width of each column, as a proportion of the total linewidth.\n\nformat_tt():\n\nNew quarto argument enables Quarto data processing for the whole table and marks specific cells as containing Quarto content. This is especially useful to include @Citation1981 in a table. Thanks to @andrewheiss for issue #215 and @giabaio for further discussion and debugging.\nNew replace argument which accepts a single logical, a single string, or a named list to specify multiple replacements.\nreplace=TRUE by default replaces NA by an empty string. FALSE prints “NA” as string.\nreplace_na is deprecated in favor of replace. Backward compatibility is maintained and a warning is issued.\nAll arguments can now be set using global options.\n\ntheme_tt():\n\n“void” is now supported for Typst tables. Thanks to @marcboschmatas for PR #223.\n\nstyle_tt():\n\nNo longer keep many versions of the same data frame, which could increase memory use. Thanks to @MarcoPortmann for the report.\n\nsave_tt():\n\nDo not change working directory when saving to file raises an error. Thanks to @etiennebacher for report #225.\n\nTypst:\n\nBetter compatibility with Quarto captions. Recommended strategy is to not use the caption argument, and rather to define both the label and tbl-cap chunk options in Quarto. This is a breaking change, as Typst tables are no longer enclosed in a #figure environment in Quarto documents when both tbl-cap and label chunk options are defined.\nformat_tt(escape=TRUE) escapes square brackets.\nTables are centered by default.\n\nMisc:\n\nSupport beamer_presentations, but see: https://github.com/vincentarelbundock/tinytable/issues/244\nTable objects can be modified and printed several times —with styling— in a single HTML document like a ReavealJS slideshow. Thanks to @kazuyanagimoto for report #759.\nGlobal option to enable Quarto data processing: options(tinytable_quarto_disable_processing = FALSE). Thanks to @andrewheiss for issue #215.\n\nBug fixes:\n\nData frames without column headers could be displayed as “c(1,2,3,3)”. Bug in format_tt(). Issue #230.\nsave_tt() can now save to PDF when the table includes a caption. Thanks to @etiennebacher for report #224.\ngroup_tt(i) inserted an extra latex column, which made horizontal lines stop to early. Thanks to @andrewheiss for report #235.\nMultiple unnamed footnotes allowed in LaTeX tabularray. Issue #242.\n\n\n\n\n\nRStudio displays table in HTML viewer by default when the rstudioapi package is available.\ncolnames and colnames<- are now exported functions.\ntt() supports data.frame-like objects which also inherit from other classes, ex: marginaleffects::slopes()\nBug: options(tinytable_tt_print) is respected in print() without argument.\n\n\n\n\nNew features:\n\nrbind() and rbind2() can be used to stack tinytable objects. rbind2() is more flexible than rbind(). See ?tinytable::rbind2\nNew output format in print(): “dataframe”\nRename table headers: colnames(tab) <- c(\"a\", \"b\", \"c\")\ntheme_tt(\"resize\") gets a direction argument with “up”, “down”, “both” options. Thanks to @MarcoPortmann for feature request #207\n\nMinor:\n\nInformative error message when no default browser is selected via global options.\nFix CRAN errors on Mac old releases.\n\nBugs:\n\ntheme_tt() resize issue with talltblr environment and notes in LaTeX. Thanks to @MarcoPortmann for reporting issue #206\n\n\n\n\nNew function theme_tt():\n\nFunction to apply collections of transformations to a tinytable.\nVisual themes:\n\ngrid, void, striped, bootstrap, default\n\nresize: Insert a LaTeX table in a resizebox environment to ensure a table fits the page, or to scale it to a fraction of \\linewidth\nplacement: Determine where a LaTeX table float is positioned. Ex: [H], [htbp]\nmultipage: Split long LaTeX tables across multiple pages with (optional) repeated headers/footers. Uses the longtblr environment from tabularray.\n\nformat_tt():\n\nNew i argument to format subsets of rows.\nNew fn argument which accepts an arbitrary function to format table content.\nnum_fmt=\"significant_cell\" rounds significant digits on a cell-by-cell basis rather than for full columns (as is default in base R format()).\nNumeric formatting options can be set via global options, defined in the function signature.\nnum_mark_big and num_mark_dec require an explicit digits. We now raise an informative error.\nescape = TRUE now escapes captions, notes, and spanning cells created by group_tt() when i and j are both NULL. To avoid escaping group labels, users can specify i and/or j explicitly.\n\nTypst format:\n\nSupport for row headers with group_tt(i)\nSupports images and inline plots with plot_tt(). Thanks to @aghaynes for contribution #155.\n“kind: tinytable” parameter is now added to all figures enclosing a tinytable. This allows users to apply targeted show rules. For example, in a table of contents: outline(target: figure.where(kind: \"tinytable\"))\n\nMisc:\n\nstyle_tt() gains a finalize argument. This accepts functions to be applied to the table object at the very end of the building process, to programmatically change its content. For example, this can be used with regular expressions to modify the text version of the table hosted in tab@table_string, or the function could programmatically modify the caption in tab@caption.\nstyle_tt(): LaTeX format supports decimal alignement with align=\"d\". The width of columns is determined by the maximum number of digits to the left and to the right in all cells specified by i, j.\nSupport RevealJS slides in Quarto documents.\nImproved support for tibble. ANSI characters (ex: fancy pillar formatting) are stripped automatically or converted to HTML when the fansi package is installed. fansi is a dependency of tibble, so it should often be installed.\nNew tinytable_tt_digits global option can set the default number of digits in the tt() function.\nRefactor: tinytable objects are now S4 class objects, with slots to hold data about the content and structure.\nas.character() now works on tinytable objects, returning a string in the output format specified by the @output slot of the tinytable object (markdown by default).\nLaTeX code in captions no longer requires double escaping, allowing: tt(x, caption = \"Blah blah \\\\label{tab:blah})\n\nBreaking changes:\n\nIn some cases, format_tt() could be use sequentially to apply two formats to the same cell. Now, multiple calls to format_tt() can still be make chained with pipes, but they must apply to different cells with i, j, otherwise only the last change is respected. One exception is the escape argument which can be applied to pre-formatted cells.\ntinytable objects no longer have a meta_tinytable attribute. Use S4 slots instead.\nplacement argument in tt() is removed in favor of theme_tt(\"placement\").\n\nBugs:\n\nformat_tt() did not work on factor vector.\n\n\n\n\n\nformat_tt() escapes <> tags in Typst.\nBug introduced in 0.0.4 prevented group_tt(i) in HTML.\n\n\n\n\nNew:\n\nj argument in style_tt() and format_tt() now accepts a string vector to match columns. Issue #122\nLine plots: plot_tt(fun = \"line\")\nformat_tt(j=NULL, escape=TRUE) now escapes column headers in addition to all cells.\nformat_tt() gains a replace_na argument to replace missing values.\nstyle_tt(): rowspan and colspan arguments are now supported in all formats except Typst. In markdown and Word, we get “pseudo-spans” with empty cells around the main cell, instead of true merged cells.\nstyle_tt(): alignv argument is now supported for LaTeX and HTML\n\nBugfix:\n\nMarkdown group columns when labels are wider than columns. Thanks to @etiennebacher for report #127.\nMarkdown group rows broke indexing when using style_tt(). Thanks to @strengejacke for report #133.\n\n\n\n\nNew:\n\nTypst tables are now supported using the tablex extension:\n\nhttps://typst.app/\nhttps://github.com/PgBiel/typst-tablex\n\nescape argument in format_tt() escapes or substitutes special characters in LaTeX or HTML output to prevent compilation and rendering errors.\nnotes argument in tt() can insert superscript markers inside cells to refer to notes at the bottom of the page.\n\ntt(x, notes = list(\"*\" = list(i = 0:1, j = 2, text = \"Hello world)))\n\nnotes agument in tt() now works wth Markdown and Word, but must be a single string.\ngroup_tt() can be called multiple times to create mult-row headers.\n\n\n\n\nImprovements:\n\nRules and cell borders: line, line_width, and line_color arguments.\nEnhanced knitr output detection.\nNew themes.\nCaption argument support for Markdown tables.\nDefensive programming enhancements.\nplot_tt() regular expression column selection.\nHeader/footer are no longer indented by group_tt(i).\n\nBug fixes:\n\nInline plots visibility in RStudio viewer pane.\nBug in group_tt(i) for markdown and docx output.\nResolved style_tt resetting issue.\nBug fix for column alignment in markdown affecting docx output.\n\nDocumentation:\n\nImproved vignette on the package website.\nVarious documentation updates.\nMath in $$ is the new recommendation.\n\n\n\n\nInitial package release. Yay!",
+ "text": "group_tt() allows 0 and duplicates in i argument for labels in the first row and consecutive labels.\nHeaders are now styled and formatted when i=NULL.\ncolnames(x)<-NULL works on a tinytable object.\nformat_tt(num_big_mark) applies to integer columns.\nPrint row names in the first column by calling options(tinytable_tt_rownames=TRUE). Thanks to @rsbivand for Issue #264.\nImproved documentation.\n\nBugs:\n\nreplace does not work in LaTeX with format_tt(quarto=TRUE). Thanks to @cbgoodman for Issue #263.\nstyle_tt(indent) works for LaTeX\n\n\n\n\nBreaking change:\n\nThe width argument is moved from style_tt() to tt().\n\ntt():\n\nwidth argument now accepts a vector of numeric values to control the width of each column, as a proportion of the total linewidth.\n\nformat_tt():\n\nNew quarto argument enables Quarto data processing for the whole table and marks specific cells as containing Quarto content. This is especially useful to include @Citation1981 in a table. Thanks to @andrewheiss for issue #215 and @giabaio for further discussion and debugging.\nNew replace argument which accepts a single logical, a single string, or a named list to specify multiple replacements.\nreplace=TRUE by default replaces NA by an empty string. FALSE prints “NA” as string.\nreplace_na is deprecated in favor of replace. Backward compatibility is maintained and a warning is issued.\nAll arguments can now be set using global options.\n\ntheme_tt():\n\n“void” is now supported for Typst tables. Thanks to @marcboschmatas for PR #223.\n\nstyle_tt():\n\nNo longer keep many versions of the same data frame, which could increase memory use. Thanks to @MarcoPortmann for the report.\n\nsave_tt():\n\nDo not change working directory when saving to file raises an error. Thanks to @etiennebacher for report #225.\n\nTypst:\n\nBetter compatibility with Quarto captions. Recommended strategy is to not use the caption argument, and rather to define both the label and tbl-cap chunk options in Quarto. This is a breaking change, as Typst tables are no longer enclosed in a #figure environment in Quarto documents when both tbl-cap and label chunk options are defined.\nformat_tt(escape=TRUE) escapes square brackets.\nTables are centered by default.\n\nMisc:\n\nSupport beamer_presentations, but see: https://github.com/vincentarelbundock/tinytable/issues/244\nTable objects can be modified and printed several times —with styling— in a single HTML document like a ReavealJS slideshow. Thanks to @kazuyanagimoto for report #759.\nGlobal option to enable Quarto data processing: options(tinytable_quarto_disable_processing = FALSE). Thanks to @andrewheiss for issue #215.\n\nBug fixes:\n\nData frames without column headers could be displayed as “c(1,2,3,3)”. Bug in format_tt(). Issue #230.\nsave_tt() can now save to PDF when the table includes a caption. Thanks to @etiennebacher for report #224.\ngroup_tt(i) inserted an extra latex column, which made horizontal lines stop to early. Thanks to @andrewheiss for report #235.\nMultiple unnamed footnotes allowed in LaTeX tabularray. Issue #242.\n\n\n\n\n\nRStudio displays table in HTML viewer by default when the rstudioapi package is available.\ncolnames and colnames<- are now exported functions.\ntt() supports data.frame-like objects which also inherit from other classes, ex: marginaleffects::slopes()\nBug: options(tinytable_tt_print) is respected in print() without argument.\n\n\n\n\nNew features:\n\nrbind() and rbind2() can be used to stack tinytable objects. rbind2() is more flexible than rbind(). See ?tinytable::rbind2\nNew output format in print(): “dataframe”\nRename table headers: colnames(tab) <- c(\"a\", \"b\", \"c\")\ntheme_tt(\"resize\") gets a direction argument with “up”, “down”, “both” options. Thanks to @MarcoPortmann for feature request #207\n\nMinor:\n\nInformative error message when no default browser is selected via global options.\nFix CRAN errors on Mac old releases.\n\nBugs:\n\ntheme_tt() resize issue with talltblr environment and notes in LaTeX. Thanks to @MarcoPortmann for reporting issue #206\n\n\n\n\nNew function theme_tt():\n\nFunction to apply collections of transformations to a tinytable.\nVisual themes:\n\ngrid, void, striped, bootstrap, default\n\nresize: Insert a LaTeX table in a resizebox environment to ensure a table fits the page, or to scale it to a fraction of \\linewidth\nplacement: Determine where a LaTeX table float is positioned. Ex: [H], [htbp]\nmultipage: Split long LaTeX tables across multiple pages with (optional) repeated headers/footers. Uses the longtblr environment from tabularray.\n\nformat_tt():\n\nNew i argument to format subsets of rows.\nNew fn argument which accepts an arbitrary function to format table content.\nnum_fmt=\"significant_cell\" rounds significant digits on a cell-by-cell basis rather than for full columns (as is default in base R format()).\nNumeric formatting options can be set via global options, defined in the function signature.\nnum_mark_big and num_mark_dec require an explicit digits. We now raise an informative error.\nescape = TRUE now escapes captions, notes, and spanning cells created by group_tt() when i and j are both NULL. To avoid escaping group labels, users can specify i and/or j explicitly.\n\nTypst format:\n\nSupport for row headers with group_tt(i)\nSupports images and inline plots with plot_tt(). Thanks to @aghaynes for contribution #155.\n“kind: tinytable” parameter is now added to all figures enclosing a tinytable. This allows users to apply targeted show rules. For example, in a table of contents: outline(target: figure.where(kind: \"tinytable\"))\n\nMisc:\n\nstyle_tt() gains a finalize argument. This accepts functions to be applied to the table object at the very end of the building process, to programmatically change its content. For example, this can be used with regular expressions to modify the text version of the table hosted in tab@table_string, or the function could programmatically modify the caption in tab@caption.\nstyle_tt(): LaTeX format supports decimal alignement with align=\"d\". The width of columns is determined by the maximum number of digits to the left and to the right in all cells specified by i, j.\nSupport RevealJS slides in Quarto documents.\nImproved support for tibble. ANSI characters (ex: fancy pillar formatting) are stripped automatically or converted to HTML when the fansi package is installed. fansi is a dependency of tibble, so it should often be installed.\nNew tinytable_tt_digits global option can set the default number of digits in the tt() function.\nRefactor: tinytable objects are now S4 class objects, with slots to hold data about the content and structure.\nas.character() now works on tinytable objects, returning a string in the output format specified by the @output slot of the tinytable object (markdown by default).\nLaTeX code in captions no longer requires double escaping, allowing: tt(x, caption = \"Blah blah \\\\label{tab:blah})\n\nBreaking changes:\n\nIn some cases, format_tt() could be use sequentially to apply two formats to the same cell. Now, multiple calls to format_tt() can still be make chained with pipes, but they must apply to different cells with i, j, otherwise only the last change is respected. One exception is the escape argument which can be applied to pre-formatted cells.\ntinytable objects no longer have a meta_tinytable attribute. Use S4 slots instead.\nplacement argument in tt() is removed in favor of theme_tt(\"placement\").\n\nBugs:\n\nformat_tt() did not work on factor vector.\n\n\n\n\n\nformat_tt() escapes <> tags in Typst.\nBug introduced in 0.0.4 prevented group_tt(i) in HTML.\n\n\n\n\nNew:\n\nj argument in style_tt() and format_tt() now accepts a string vector to match columns. Issue #122\nLine plots: plot_tt(fun = \"line\")\nformat_tt(j=NULL, escape=TRUE) now escapes column headers in addition to all cells.\nformat_tt() gains a replace_na argument to replace missing values.\nstyle_tt(): rowspan and colspan arguments are now supported in all formats except Typst. In markdown and Word, we get “pseudo-spans” with empty cells around the main cell, instead of true merged cells.\nstyle_tt(): alignv argument is now supported for LaTeX and HTML\n\nBugfix:\n\nMarkdown group columns when labels are wider than columns. Thanks to @etiennebacher for report #127.\nMarkdown group rows broke indexing when using style_tt(). Thanks to @strengejacke for report #133.\n\n\n\n\nNew:\n\nTypst tables are now supported using the tablex extension:\n\nhttps://typst.app/\nhttps://github.com/PgBiel/typst-tablex\n\nescape argument in format_tt() escapes or substitutes special characters in LaTeX or HTML output to prevent compilation and rendering errors.\nnotes argument in tt() can insert superscript markers inside cells to refer to notes at the bottom of the page.\n\ntt(x, notes = list(\"*\" = list(i = 0:1, j = 2, text = \"Hello world)))\n\nnotes agument in tt() now works wth Markdown and Word, but must be a single string.\ngroup_tt() can be called multiple times to create mult-row headers.\n\n\n\n\nImprovements:\n\nRules and cell borders: line, line_width, and line_color arguments.\nEnhanced knitr output detection.\nNew themes.\nCaption argument support for Markdown tables.\nDefensive programming enhancements.\nplot_tt() regular expression column selection.\nHeader/footer are no longer indented by group_tt(i).\n\nBug fixes:\n\nInline plots visibility in RStudio viewer pane.\nBug in group_tt(i) for markdown and docx output.\nResolved style_tt resetting issue.\nBug fix for column alignment in markdown affecting docx output.\n\nDocumentation:\n\nImproved vignette on the package website.\nVarious documentation updates.\nMath in $$ is the new recommendation.\n\n\n\n\nInitial package release. Yay!",
"crumbs": [
"Tutorial (PDF)",
"News"
@@ -332,7 +332,7 @@
"href": "NEWS.html#development",
"title": "News",
"section": "",
- "text": "Headers are now styled and formatted when i=NULL.\ncolnames(x)<-NULL works on a tinytable object.\nformat_tt(num_big_mark) applies to integer columns.\nPrint row names in the first column by calling options(tinytable_tt_rownames=TRUE). Thanks to @rsbivand for Issue #264.\nImproved documentation.\n\nBugs:\n\nreplace does not work in LaTeX with format_tt(quarto=TRUE). Thanks to @cbgoodman for Issue #263.\nstyle_tt(indent) works for LaTeX",
+ "text": "group_tt() allows 0 and duplicates in i argument for labels in the first row and consecutive labels.\nHeaders are now styled and formatted when i=NULL.\ncolnames(x)<-NULL works on a tinytable object.\nformat_tt(num_big_mark) applies to integer columns.\nPrint row names in the first column by calling options(tinytable_tt_rownames=TRUE). Thanks to @rsbivand for Issue #264.\nImproved documentation.\n\nBugs:\n\nreplace does not work in LaTeX with format_tt(quarto=TRUE). Thanks to @cbgoodman for Issue #263.\nstyle_tt(indent) works for LaTeX",
"crumbs": [
"Tutorial (PDF)",
"News"
@@ -534,7 +534,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 = getOption(\"tinytable_format_digits\", default = NULL),\n num_fmt = getOption(\"tinytable_format_num_fmt\", default = \"significant\"),\n num_zero = getOption(\"tinytable_format_num_zero\", default = FALSE),\n num_suffix = getOption(\"tinytable_format_num_suffix\", default = FALSE),\n num_mark_big = getOption(\"tinytable_format_num_mark_big\", default = \"\"),\n num_mark_dec = getOption(\"tinytable_format_num_mark_dec\", default = getOption(\"OutDec\",\n default = \".\")),\n date = getOption(\"tinytable_format_date\", default = \"%Y-%m-%d\"),\n bool = getOption(\"tinytable_format_bool\", default = function(column)\n tools::toTitleCase(tolower(column))),\n other = getOption(\"tinytable_format_other\", default = as.character),\n replace = getOption(\"tinytable_format_replace\", default = TRUE),\n escape = getOption(\"tinytable_format_escape\", default = FALSE),\n markdown = getOption(\"tinytable_format_markdown\", default = FALSE),\n quarto = getOption(\"tinytable_format_quarto\", default = FALSE),\n fn = getOption(\"tinytable_format_fn\", default = NULL),\n sprintf = getOption(\"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\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\nWhen the x data frame includes row names, tinytable can bind them to the first column (without an empty string string as column name). This global option triggers this behavior:\n\noptions(tinytable_tt_rownames = TRUE)\n\nx <- mtcars[1:3, 1:3]\ntt(x)\n\noptions(tinytable_tt_rownames = FALSE)\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\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 tinytable_1qw0qru5e95a20fvutzu\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 10 000\n 10 001\n \n \n 10 000\n 10 000\n \n \n 10 000\n 9 999\n \n \n \n \n\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 tinytable_2eg48c1ekoz54lriwlgn\n \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\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 tinytable_zevl7x5xliwvknozrqbm\n \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 \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 tinytable_brpyts5e5c79i22ulef9\n \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 \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 tinytable_nd3zv6mixpo7ubr47tgc\n \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 \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 tinytable_1c4udocrldhy79m57bqh\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\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 tinytable_l9n3cxj3rn861pfy60mq\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>",
+ "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 = getOption(\"tinytable_format_digits\", default = NULL),\n num_fmt = getOption(\"tinytable_format_num_fmt\", default = \"significant\"),\n num_zero = getOption(\"tinytable_format_num_zero\", default = FALSE),\n num_suffix = getOption(\"tinytable_format_num_suffix\", default = FALSE),\n num_mark_big = getOption(\"tinytable_format_num_mark_big\", default = \"\"),\n num_mark_dec = getOption(\"tinytable_format_num_mark_dec\", default = getOption(\"OutDec\",\n default = \".\")),\n date = getOption(\"tinytable_format_date\", default = \"%Y-%m-%d\"),\n bool = getOption(\"tinytable_format_bool\", default = function(column)\n tools::toTitleCase(tolower(column))),\n other = getOption(\"tinytable_format_other\", default = as.character),\n replace = getOption(\"tinytable_format_replace\", default = TRUE),\n escape = getOption(\"tinytable_format_escape\", default = FALSE),\n markdown = getOption(\"tinytable_format_markdown\", default = FALSE),\n quarto = getOption(\"tinytable_format_quarto\", default = FALSE),\n fn = getOption(\"tinytable_format_fn\", default = NULL),\n sprintf = getOption(\"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\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\nWhen the x data frame includes row names, tinytable can bind them to the first column (without an empty string string as column name). This global option triggers this behavior:\n\noptions(tinytable_tt_rownames = TRUE)\n\nx <- mtcars[1:3, 1:3]\ntt(x)\n\noptions(tinytable_tt_rownames = FALSE)\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\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 tinytable_fo2mzsmwyubzv6l7w55b\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 10 001\n 9 999\n \n \n 10 001\n 9 998\n \n \n 10 000\n 10 002\n \n \n \n \n\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 tinytable_bjgrk8lwzqxdd400d3do\n \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\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 tinytable_u6mr9vgc8nnatn3jaain\n \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 \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 tinytable_nuz9vdo8nd525kctr7ht\n \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 \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 tinytable_8k78m27pf0xgtjinn26x\n \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 \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 tinytable_2k39h6tt5yqfl0xx34bo\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\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 tinytable_43pf9o0mhbpwjw2pays8\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>",
"crumbs": [
"Tutorial (PDF)",
"Functions",
@@ -546,7 +546,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 = getOption(\"tinytable_format_digits\", default = NULL),\n num_fmt = getOption(\"tinytable_format_num_fmt\", default = \"significant\"),\n num_zero = getOption(\"tinytable_format_num_zero\", default = FALSE),\n num_suffix = getOption(\"tinytable_format_num_suffix\", default = FALSE),\n num_mark_big = getOption(\"tinytable_format_num_mark_big\", default = \"\"),\n num_mark_dec = getOption(\"tinytable_format_num_mark_dec\", default = getOption(\"OutDec\",\n default = \".\")),\n date = getOption(\"tinytable_format_date\", default = \"%Y-%m-%d\"),\n bool = getOption(\"tinytable_format_bool\", default = function(column)\n tools::toTitleCase(tolower(column))),\n other = getOption(\"tinytable_format_other\", default = as.character),\n replace = getOption(\"tinytable_format_replace\", default = TRUE),\n escape = getOption(\"tinytable_format_escape\", default = FALSE),\n markdown = getOption(\"tinytable_format_markdown\", default = FALSE),\n quarto = getOption(\"tinytable_format_quarto\", default = FALSE),\n fn = getOption(\"tinytable_format_fn\", default = NULL),\n sprintf = getOption(\"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\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\nWhen the x data frame includes row names, tinytable can bind them to the first column (without an empty string string as column name). This global option triggers this behavior:\n\noptions(tinytable_tt_rownames = TRUE)\n\nx <- mtcars[1:3, 1:3]\ntt(x)\n\noptions(tinytable_tt_rownames = FALSE)\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\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 tinytable_1qw0qru5e95a20fvutzu\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 10 000\n 10 001\n \n \n 10 000\n 10 000\n \n \n 10 000\n 9 999\n \n \n \n \n\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 tinytable_2eg48c1ekoz54lriwlgn\n \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\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 tinytable_zevl7x5xliwvknozrqbm\n \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 \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 tinytable_brpyts5e5c79i22ulef9\n \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 \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 tinytable_nd3zv6mixpo7ubr47tgc\n \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 \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 tinytable_1c4udocrldhy79m57bqh\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\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 tinytable_l9n3cxj3rn861pfy60mq\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>",
+ "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 = getOption(\"tinytable_format_digits\", default = NULL),\n num_fmt = getOption(\"tinytable_format_num_fmt\", default = \"significant\"),\n num_zero = getOption(\"tinytable_format_num_zero\", default = FALSE),\n num_suffix = getOption(\"tinytable_format_num_suffix\", default = FALSE),\n num_mark_big = getOption(\"tinytable_format_num_mark_big\", default = \"\"),\n num_mark_dec = getOption(\"tinytable_format_num_mark_dec\", default = getOption(\"OutDec\",\n default = \".\")),\n date = getOption(\"tinytable_format_date\", default = \"%Y-%m-%d\"),\n bool = getOption(\"tinytable_format_bool\", default = function(column)\n tools::toTitleCase(tolower(column))),\n other = getOption(\"tinytable_format_other\", default = as.character),\n replace = getOption(\"tinytable_format_replace\", default = TRUE),\n escape = getOption(\"tinytable_format_escape\", default = FALSE),\n markdown = getOption(\"tinytable_format_markdown\", default = FALSE),\n quarto = getOption(\"tinytable_format_quarto\", default = FALSE),\n fn = getOption(\"tinytable_format_fn\", default = NULL),\n sprintf = getOption(\"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\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\nWhen the x data frame includes row names, tinytable can bind them to the first column (without an empty string string as column name). This global option triggers this behavior:\n\noptions(tinytable_tt_rownames = TRUE)\n\nx <- mtcars[1:3, 1:3]\ntt(x)\n\noptions(tinytable_tt_rownames = FALSE)\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\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 tinytable_fo2mzsmwyubzv6l7w55b\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 10 001\n 9 999\n \n \n 10 001\n 9 998\n \n \n 10 000\n 10 002\n \n \n \n \n\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 tinytable_bjgrk8lwzqxdd400d3do\n \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\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 tinytable_u6mr9vgc8nnatn3jaain\n \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 \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 tinytable_nuz9vdo8nd525kctr7ht\n \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 \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 tinytable_8k78m27pf0xgtjinn26x\n \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 \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 tinytable_2k39h6tt5yqfl0xx34bo\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\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 tinytable_43pf9o0mhbpwjw2pays8\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>",
"crumbs": [
"Tutorial (PDF)",
"Functions",
@@ -558,7 +558,7 @@
"href": "man/tt.html",
"title": "tinytable",
"section": "",
- "text": "The tt function renders a table in different formats with various styling options: HTML, Markdown, LaTeX, Word, PDF, PNG, or Typst. The table can be customized with additional functions:\n\n\nstyle_tt(): style fonts, colors, alignment, etc.\n\n\nformat_tt(): format numbers, dates, strings, etc.\n\n\ngroup_tt(): row or column group labels.\n\n\ntheme_tt(): apply a collection of transformations to a tinytable.\n\n\nsave_tt(): save the table to a file or return the table as a string.\n\n\nprint(): print to a specific format, ex: print(x, “latex”)\n\n\ntinytable attempts to determine the appropriate way to print the table based on interactive use, RStudio availability, and output format in RMarkdown or Quarto documents. Users can call print(x, output=“markdown”) to print the table in a specific format. Alternatively, they can set a global option: options(“tinytable_print_output”=“markdown”)\n\n\n\ntt(\n x,\n digits = getOption(\"tinytable_tt_digits\", default = NULL),\n caption = getOption(\"tinytable_tt_caption\", default = NULL),\n notes = getOption(\"tinytable_tt_notes\", default = NULL),\n width = getOption(\"tinytable_tt_width\", default = NULL),\n theme = getOption(\"tinytable_tt_theme\", default = NULL),\n ...\n)\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\ndigits\n\n\nNumber of significant digits to keep for numeric variables. When digits is an integer, tt() calls format_tt(x, digits = digits) before proceeding to draw the table. Note that this will apply all default argument values of format_tt(), such as replacing NA by \"\". Users who need more control can use the format_tt() function instead.\n\n\n\n\ncaption\n\n\nA string that will be used as the caption of the table. This argument should not be used in Quarto or Rmarkdown documents. In that context, please use the appropriate chunk options.\n\n\n\n\nnotes\n\n\nNotes to append to the bottom of the table. This argument accepts several different inputs:\n\n\nSingle string insert a single note: “blah blah”\n\n\nMultiple strings insert multiple notes sequentially: list(“Hello world”, “Foo bar”)\n\n\nA named list inserts a list with the name as superscript: list(“a” = list(“Hello World”))\n\n\nA named list with positions inserts markers as superscripts inside table cells: list(“a” = list(i = 0:1, j = 2, text = “Hello World”))\n\n\n\n\n\n\nwidth\n\n\nTable or column width.\n\n\nSingle numeric value smaller than or equal to 1 determines the full table width, in proportion of line width.\n\n\nNumeric vector of length equal to the number of columns in x determines the width of each column, in proportion of line width. If the sum of width exceeds 1, each element is divided by sum(width). This makes the table full-width with relative column sizes.\n\n\n\n\n\n\ntheme\n\n\nFunction or string.\n\n\nString: grid, resize, multipage, placement, striped, void, bootstrap, tabular\n\n\nFunction: Applied to the tinytable object.\n\n\n\n\n\n\n…\n\n\nAdditional arguments are ignored\n\n\n\n\n\n\nAn object of class tt representing the table.\nThe table object has S4 slots which hold information about the structure of the table. This meta-data can be accessed with the usual @ accessor. In general, modifying the content of these slots is not recommended, but it can be useful to some developers, such as those who want to force print to a specific output format without calling print().\n\n\n\ntinytable uses the tabularray package from your LaTeX distribution to draw tables. tabularray, in turn, uses the special tblr, talltblr, and longtblr environments.\nWhen rendering a document from Quarto or Rmarkdown directly to PDF, tinytable will populate the LaTeX preamble automatically with all the required packages (except when code chunks are cached). For standalone LaTeX documents, these commands should be inserted in the preamble manually:\n\n\\usepackage{tabularray}\n\\usepackage{float}\n\\usepackage{graphicx}\n\\usepackage[normalem]{ulem}\n\\UseTblrLibrary{booktabs}\n\\UseTblrLibrary{siunitx}\n\\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline{#1}}\n\\newcommand{\\tinytableTabularrayStrikeout}[1]{\\sout{#1}}\n\\NewTableCommand{\\tinytableDefineColor}[3]{\\definecolor{#1}{#2}{#3}}\n\n\n\n\n\n\nWhen the x data frame includes row names, tinytable can bind them to the first column (without an empty string string as column name). This global option triggers this behavior:\n\noptions(tinytable_tt_rownames = TRUE)\n\nx <- mtcars[1:3, 1:3]\ntt(x)\n\noptions(tinytable_tt_rownames = FALSE)\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\n\nlibrary(tinytable)\n\nlibrary(tinytable)\nx <- mtcars[1:4, 1:5]\n\ntt(x)\n\n \n\n \n \n \n tinytable_g6r84r5wkqo3f48e07yg\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.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x,\n theme = \"striped\",\n width = 0.5,\n caption = \"Data about cars.\")\n\n \n\n \n \n \n tinytable_2c0x4b0dpfjoaldh68l9\n \n \n \n \n \n\n \n \n \n \n Data about cars.\n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x, notes = \"Hello World!\")\n\n \n\n \n \n \n tinytable_jy8uiij1nenb392siwqa\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 Hello World!\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\nfn <- list(i = 0:1, j = 2, text = \"Hello World!\")\ntab <- tt(x, notes = list(\"*\" = fn))\nprint(tab, \"latex\")\n\n\\begin{table}\n\\centering\n\\begin{talltblr}[ %% tabularray outer open\nentry=none,label=none,\nnote{*}={Hello World!},\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nmpg & cyl\\textsuperscript{*} & disp & hp & drat \\\\ \\midrule %% TinyTableHeader\n21.0 & 6\\textsuperscript{*} & 160 & 110 & 3.90 \\\\\n21.0 & 6 & 160 & 110 & 3.90 \\\\\n22.8 & 4 & 108 & 93 & 3.85 \\\\\n21.4 & 6 & 258 & 110 & 3.08 \\\\\n\\bottomrule\n\\end{talltblr}\n\\end{table} \n\nk <- data.frame(x = c(0.000123456789, 12.4356789))\ntt(k, digits=2)\n\n \n\n \n \n \n tinytable_3s6bu3z5djmeu2ao3h73\n \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",
+ "text": "The tt function renders a table in different formats with various styling options: HTML, Markdown, LaTeX, Word, PDF, PNG, or Typst. The table can be customized with additional functions:\n\n\nstyle_tt(): style fonts, colors, alignment, etc.\n\n\nformat_tt(): format numbers, dates, strings, etc.\n\n\ngroup_tt(): row or column group labels.\n\n\ntheme_tt(): apply a collection of transformations to a tinytable.\n\n\nsave_tt(): save the table to a file or return the table as a string.\n\n\nprint(): print to a specific format, ex: print(x, “latex”)\n\n\ntinytable attempts to determine the appropriate way to print the table based on interactive use, RStudio availability, and output format in RMarkdown or Quarto documents. Users can call print(x, output=“markdown”) to print the table in a specific format. Alternatively, they can set a global option: options(“tinytable_print_output”=“markdown”)\n\n\n\ntt(\n x,\n digits = getOption(\"tinytable_tt_digits\", default = NULL),\n caption = getOption(\"tinytable_tt_caption\", default = NULL),\n notes = getOption(\"tinytable_tt_notes\", default = NULL),\n width = getOption(\"tinytable_tt_width\", default = NULL),\n theme = getOption(\"tinytable_tt_theme\", default = NULL),\n ...\n)\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\ndigits\n\n\nNumber of significant digits to keep for numeric variables. When digits is an integer, tt() calls format_tt(x, digits = digits) before proceeding to draw the table. Note that this will apply all default argument values of format_tt(), such as replacing NA by \"\". Users who need more control can use the format_tt() function instead.\n\n\n\n\ncaption\n\n\nA string that will be used as the caption of the table. This argument should not be used in Quarto or Rmarkdown documents. In that context, please use the appropriate chunk options.\n\n\n\n\nnotes\n\n\nNotes to append to the bottom of the table. This argument accepts several different inputs:\n\n\nSingle string insert a single note: “blah blah”\n\n\nMultiple strings insert multiple notes sequentially: list(“Hello world”, “Foo bar”)\n\n\nA named list inserts a list with the name as superscript: list(“a” = list(“Hello World”))\n\n\nA named list with positions inserts markers as superscripts inside table cells: list(“a” = list(i = 0:1, j = 2, text = “Hello World”))\n\n\n\n\n\n\nwidth\n\n\nTable or column width.\n\n\nSingle numeric value smaller than or equal to 1 determines the full table width, in proportion of line width.\n\n\nNumeric vector of length equal to the number of columns in x determines the width of each column, in proportion of line width. If the sum of width exceeds 1, each element is divided by sum(width). This makes the table full-width with relative column sizes.\n\n\n\n\n\n\ntheme\n\n\nFunction or string.\n\n\nString: grid, resize, multipage, placement, striped, void, bootstrap, tabular\n\n\nFunction: Applied to the tinytable object.\n\n\n\n\n\n\n…\n\n\nAdditional arguments are ignored\n\n\n\n\n\n\nAn object of class tt representing the table.\nThe table object has S4 slots which hold information about the structure of the table. This meta-data can be accessed with the usual @ accessor. In general, modifying the content of these slots is not recommended, but it can be useful to some developers, such as those who want to force print to a specific output format without calling print().\n\n\n\ntinytable uses the tabularray package from your LaTeX distribution to draw tables. tabularray, in turn, uses the special tblr, talltblr, and longtblr environments.\nWhen rendering a document from Quarto or Rmarkdown directly to PDF, tinytable will populate the LaTeX preamble automatically with all the required packages (except when code chunks are cached). For standalone LaTeX documents, these commands should be inserted in the preamble manually:\n\n\\usepackage{tabularray}\n\\usepackage{float}\n\\usepackage{graphicx}\n\\usepackage[normalem]{ulem}\n\\UseTblrLibrary{booktabs}\n\\UseTblrLibrary{siunitx}\n\\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline{#1}}\n\\newcommand{\\tinytableTabularrayStrikeout}[1]{\\sout{#1}}\n\\NewTableCommand{\\tinytableDefineColor}[3]{\\definecolor{#1}{#2}{#3}}\n\n\n\n\n\n\nWhen the x data frame includes row names, tinytable can bind them to the first column (without an empty string string as column name). This global option triggers this behavior:\n\noptions(tinytable_tt_rownames = TRUE)\n\nx <- mtcars[1:3, 1:3]\ntt(x)\n\noptions(tinytable_tt_rownames = FALSE)\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\n\nlibrary(tinytable)\n\nlibrary(tinytable)\nx <- mtcars[1:4, 1:5]\n\ntt(x)\n\n \n\n \n \n \n tinytable_x23mayhr3r9toesv2nc2\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.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x,\n theme = \"striped\",\n width = 0.5,\n caption = \"Data about cars.\")\n\n \n\n \n \n \n tinytable_t42bj77w01ywpyb7ygcr\n \n \n \n \n \n\n \n \n \n \n Data about cars.\n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x, notes = \"Hello World!\")\n\n \n\n \n \n \n tinytable_9iqvoeb1n1xsbbczbloz\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 Hello World!\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\nfn <- list(i = 0:1, j = 2, text = \"Hello World!\")\ntab <- tt(x, notes = list(\"*\" = fn))\nprint(tab, \"latex\")\n\n\\begin{table}\n\\centering\n\\begin{talltblr}[ %% tabularray outer open\nentry=none,label=none,\nnote{*}={Hello World!},\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nmpg & cyl\\textsuperscript{*} & disp & hp & drat \\\\ \\midrule %% TinyTableHeader\n21.0 & 6\\textsuperscript{*} & 160 & 110 & 3.90 \\\\\n21.0 & 6 & 160 & 110 & 3.90 \\\\\n22.8 & 4 & 108 & 93 & 3.85 \\\\\n21.4 & 6 & 258 & 110 & 3.08 \\\\\n\\bottomrule\n\\end{talltblr}\n\\end{table} \n\nk <- data.frame(x = c(0.000123456789, 12.4356789))\ntt(k, digits=2)\n\n \n\n \n \n \n tinytable_rtem9rp6j5mkstpt6lvc\n \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",
"crumbs": [
"Tutorial (PDF)",
"Functions",
@@ -570,7 +570,7 @@
"href": "man/tt.html#draw-a-tiny-table",
"title": "tinytable",
"section": "",
- "text": "The tt function renders a table in different formats with various styling options: HTML, Markdown, LaTeX, Word, PDF, PNG, or Typst. The table can be customized with additional functions:\n\n\nstyle_tt(): style fonts, colors, alignment, etc.\n\n\nformat_tt(): format numbers, dates, strings, etc.\n\n\ngroup_tt(): row or column group labels.\n\n\ntheme_tt(): apply a collection of transformations to a tinytable.\n\n\nsave_tt(): save the table to a file or return the table as a string.\n\n\nprint(): print to a specific format, ex: print(x, “latex”)\n\n\ntinytable attempts to determine the appropriate way to print the table based on interactive use, RStudio availability, and output format in RMarkdown or Quarto documents. Users can call print(x, output=“markdown”) to print the table in a specific format. Alternatively, they can set a global option: options(“tinytable_print_output”=“markdown”)\n\n\n\ntt(\n x,\n digits = getOption(\"tinytable_tt_digits\", default = NULL),\n caption = getOption(\"tinytable_tt_caption\", default = NULL),\n notes = getOption(\"tinytable_tt_notes\", default = NULL),\n width = getOption(\"tinytable_tt_width\", default = NULL),\n theme = getOption(\"tinytable_tt_theme\", default = NULL),\n ...\n)\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\ndigits\n\n\nNumber of significant digits to keep for numeric variables. When digits is an integer, tt() calls format_tt(x, digits = digits) before proceeding to draw the table. Note that this will apply all default argument values of format_tt(), such as replacing NA by \"\". Users who need more control can use the format_tt() function instead.\n\n\n\n\ncaption\n\n\nA string that will be used as the caption of the table. This argument should not be used in Quarto or Rmarkdown documents. In that context, please use the appropriate chunk options.\n\n\n\n\nnotes\n\n\nNotes to append to the bottom of the table. This argument accepts several different inputs:\n\n\nSingle string insert a single note: “blah blah”\n\n\nMultiple strings insert multiple notes sequentially: list(“Hello world”, “Foo bar”)\n\n\nA named list inserts a list with the name as superscript: list(“a” = list(“Hello World”))\n\n\nA named list with positions inserts markers as superscripts inside table cells: list(“a” = list(i = 0:1, j = 2, text = “Hello World”))\n\n\n\n\n\n\nwidth\n\n\nTable or column width.\n\n\nSingle numeric value smaller than or equal to 1 determines the full table width, in proportion of line width.\n\n\nNumeric vector of length equal to the number of columns in x determines the width of each column, in proportion of line width. If the sum of width exceeds 1, each element is divided by sum(width). This makes the table full-width with relative column sizes.\n\n\n\n\n\n\ntheme\n\n\nFunction or string.\n\n\nString: grid, resize, multipage, placement, striped, void, bootstrap, tabular\n\n\nFunction: Applied to the tinytable object.\n\n\n\n\n\n\n…\n\n\nAdditional arguments are ignored\n\n\n\n\n\n\nAn object of class tt representing the table.\nThe table object has S4 slots which hold information about the structure of the table. This meta-data can be accessed with the usual @ accessor. In general, modifying the content of these slots is not recommended, but it can be useful to some developers, such as those who want to force print to a specific output format without calling print().\n\n\n\ntinytable uses the tabularray package from your LaTeX distribution to draw tables. tabularray, in turn, uses the special tblr, talltblr, and longtblr environments.\nWhen rendering a document from Quarto or Rmarkdown directly to PDF, tinytable will populate the LaTeX preamble automatically with all the required packages (except when code chunks are cached). For standalone LaTeX documents, these commands should be inserted in the preamble manually:\n\n\\usepackage{tabularray}\n\\usepackage{float}\n\\usepackage{graphicx}\n\\usepackage[normalem]{ulem}\n\\UseTblrLibrary{booktabs}\n\\UseTblrLibrary{siunitx}\n\\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline{#1}}\n\\newcommand{\\tinytableTabularrayStrikeout}[1]{\\sout{#1}}\n\\NewTableCommand{\\tinytableDefineColor}[3]{\\definecolor{#1}{#2}{#3}}\n\n\n\n\n\n\nWhen the x data frame includes row names, tinytable can bind them to the first column (without an empty string string as column name). This global option triggers this behavior:\n\noptions(tinytable_tt_rownames = TRUE)\n\nx <- mtcars[1:3, 1:3]\ntt(x)\n\noptions(tinytable_tt_rownames = FALSE)\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\n\nlibrary(tinytable)\n\nlibrary(tinytable)\nx <- mtcars[1:4, 1:5]\n\ntt(x)\n\n \n\n \n \n \n tinytable_g6r84r5wkqo3f48e07yg\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.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x,\n theme = \"striped\",\n width = 0.5,\n caption = \"Data about cars.\")\n\n \n\n \n \n \n tinytable_2c0x4b0dpfjoaldh68l9\n \n \n \n \n \n\n \n \n \n \n Data about cars.\n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x, notes = \"Hello World!\")\n\n \n\n \n \n \n tinytable_jy8uiij1nenb392siwqa\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 Hello World!\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\nfn <- list(i = 0:1, j = 2, text = \"Hello World!\")\ntab <- tt(x, notes = list(\"*\" = fn))\nprint(tab, \"latex\")\n\n\\begin{table}\n\\centering\n\\begin{talltblr}[ %% tabularray outer open\nentry=none,label=none,\nnote{*}={Hello World!},\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nmpg & cyl\\textsuperscript{*} & disp & hp & drat \\\\ \\midrule %% TinyTableHeader\n21.0 & 6\\textsuperscript{*} & 160 & 110 & 3.90 \\\\\n21.0 & 6 & 160 & 110 & 3.90 \\\\\n22.8 & 4 & 108 & 93 & 3.85 \\\\\n21.4 & 6 & 258 & 110 & 3.08 \\\\\n\\bottomrule\n\\end{talltblr}\n\\end{table} \n\nk <- data.frame(x = c(0.000123456789, 12.4356789))\ntt(k, digits=2)\n\n \n\n \n \n \n tinytable_3s6bu3z5djmeu2ao3h73\n \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",
+ "text": "The tt function renders a table in different formats with various styling options: HTML, Markdown, LaTeX, Word, PDF, PNG, or Typst. The table can be customized with additional functions:\n\n\nstyle_tt(): style fonts, colors, alignment, etc.\n\n\nformat_tt(): format numbers, dates, strings, etc.\n\n\ngroup_tt(): row or column group labels.\n\n\ntheme_tt(): apply a collection of transformations to a tinytable.\n\n\nsave_tt(): save the table to a file or return the table as a string.\n\n\nprint(): print to a specific format, ex: print(x, “latex”)\n\n\ntinytable attempts to determine the appropriate way to print the table based on interactive use, RStudio availability, and output format in RMarkdown or Quarto documents. Users can call print(x, output=“markdown”) to print the table in a specific format. Alternatively, they can set a global option: options(“tinytable_print_output”=“markdown”)\n\n\n\ntt(\n x,\n digits = getOption(\"tinytable_tt_digits\", default = NULL),\n caption = getOption(\"tinytable_tt_caption\", default = NULL),\n notes = getOption(\"tinytable_tt_notes\", default = NULL),\n width = getOption(\"tinytable_tt_width\", default = NULL),\n theme = getOption(\"tinytable_tt_theme\", default = NULL),\n ...\n)\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\ndigits\n\n\nNumber of significant digits to keep for numeric variables. When digits is an integer, tt() calls format_tt(x, digits = digits) before proceeding to draw the table. Note that this will apply all default argument values of format_tt(), such as replacing NA by \"\". Users who need more control can use the format_tt() function instead.\n\n\n\n\ncaption\n\n\nA string that will be used as the caption of the table. This argument should not be used in Quarto or Rmarkdown documents. In that context, please use the appropriate chunk options.\n\n\n\n\nnotes\n\n\nNotes to append to the bottom of the table. This argument accepts several different inputs:\n\n\nSingle string insert a single note: “blah blah”\n\n\nMultiple strings insert multiple notes sequentially: list(“Hello world”, “Foo bar”)\n\n\nA named list inserts a list with the name as superscript: list(“a” = list(“Hello World”))\n\n\nA named list with positions inserts markers as superscripts inside table cells: list(“a” = list(i = 0:1, j = 2, text = “Hello World”))\n\n\n\n\n\n\nwidth\n\n\nTable or column width.\n\n\nSingle numeric value smaller than or equal to 1 determines the full table width, in proportion of line width.\n\n\nNumeric vector of length equal to the number of columns in x determines the width of each column, in proportion of line width. If the sum of width exceeds 1, each element is divided by sum(width). This makes the table full-width with relative column sizes.\n\n\n\n\n\n\ntheme\n\n\nFunction or string.\n\n\nString: grid, resize, multipage, placement, striped, void, bootstrap, tabular\n\n\nFunction: Applied to the tinytable object.\n\n\n\n\n\n\n…\n\n\nAdditional arguments are ignored\n\n\n\n\n\n\nAn object of class tt representing the table.\nThe table object has S4 slots which hold information about the structure of the table. This meta-data can be accessed with the usual @ accessor. In general, modifying the content of these slots is not recommended, but it can be useful to some developers, such as those who want to force print to a specific output format without calling print().\n\n\n\ntinytable uses the tabularray package from your LaTeX distribution to draw tables. tabularray, in turn, uses the special tblr, talltblr, and longtblr environments.\nWhen rendering a document from Quarto or Rmarkdown directly to PDF, tinytable will populate the LaTeX preamble automatically with all the required packages (except when code chunks are cached). For standalone LaTeX documents, these commands should be inserted in the preamble manually:\n\n\\usepackage{tabularray}\n\\usepackage{float}\n\\usepackage{graphicx}\n\\usepackage[normalem]{ulem}\n\\UseTblrLibrary{booktabs}\n\\UseTblrLibrary{siunitx}\n\\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline{#1}}\n\\newcommand{\\tinytableTabularrayStrikeout}[1]{\\sout{#1}}\n\\NewTableCommand{\\tinytableDefineColor}[3]{\\definecolor{#1}{#2}{#3}}\n\n\n\n\n\n\nWhen the x data frame includes row names, tinytable can bind them to the first column (without an empty string string as column name). This global option triggers this behavior:\n\noptions(tinytable_tt_rownames = TRUE)\n\nx <- mtcars[1:3, 1:3]\ntt(x)\n\noptions(tinytable_tt_rownames = FALSE)\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\n\nlibrary(tinytable)\n\nlibrary(tinytable)\nx <- mtcars[1:4, 1:5]\n\ntt(x)\n\n \n\n \n \n \n tinytable_x23mayhr3r9toesv2nc2\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.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x,\n theme = \"striped\",\n width = 0.5,\n caption = \"Data about cars.\")\n\n \n\n \n \n \n tinytable_t42bj77w01ywpyb7ygcr\n \n \n \n \n \n\n \n \n \n \n Data about cars.\n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x, notes = \"Hello World!\")\n\n \n\n \n \n \n tinytable_9iqvoeb1n1xsbbczbloz\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 Hello World!\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\nfn <- list(i = 0:1, j = 2, text = \"Hello World!\")\ntab <- tt(x, notes = list(\"*\" = fn))\nprint(tab, \"latex\")\n\n\\begin{table}\n\\centering\n\\begin{talltblr}[ %% tabularray outer open\nentry=none,label=none,\nnote{*}={Hello World!},\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nmpg & cyl\\textsuperscript{*} & disp & hp & drat \\\\ \\midrule %% TinyTableHeader\n21.0 & 6\\textsuperscript{*} & 160 & 110 & 3.90 \\\\\n21.0 & 6 & 160 & 110 & 3.90 \\\\\n22.8 & 4 & 108 & 93 & 3.85 \\\\\n21.4 & 6 & 258 & 110 & 3.08 \\\\\n\\bottomrule\n\\end{talltblr}\n\\end{table} \n\nk <- data.frame(x = c(0.000123456789, 12.4356789))\ntt(k, digits=2)\n\n \n\n \n \n \n tinytable_rtem9rp6j5mkstpt6lvc\n \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",
"crumbs": [
"Tutorial (PDF)",
"Functions",
@@ -582,7 +582,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 tinytable_6fxfmc8yiwp2bz0o2g5n\n \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-09-09\n True \n \n \n 201399\n 201.4 \n 1972-09-27\n True \n \n \n 100188\n 0.13\n 1970-05-10\n False\n \n \n \n \n\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 tinytable_j57ukfsng7a19s4dneoj\n \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 September 09 1971\n True\n \n \n 201 399,18\n 201.4\n September 27 1972\n True\n \n \n 100 188,39\n 0.1\n May 10 1970\n False\n \n \n \n \n\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 tinytable_7drb9moylxd2kx9pmvaa\n \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\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 tinytable_ki99hrfy8a8mqlri9h0x\n \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\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 tinytable_3j2uc0mee8152dh67895\n \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\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 tinytable_adl4ehwmivgwh3wp6qe7\n \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\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 tinytable_0xszfelbkhjqs051awux\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 \n\n \n\n\n\ntt(tab) |> format_tt()\n\n \n\n \n \n \n tinytable_w3etbtsb7c9rusa3i2vb\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\n \n\n\n\ntt(tab) |> format_tt(replace = \"-\")\n\n \n\n \n \n \n tinytable_4zb2jhv6yu413z1yh0tx\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\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 tinytable_9thjshodw1t66m3u1gm0\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\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 tinytable_x77dgundaipxuftz6658\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\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 tinytable_tldwof2xz3yatnu1bfcw\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\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 tinytable_295fmu5lmillx49gx8d7\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\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 tinytable_8iuc2w6mh3mrs6lu28tm\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\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 tinytable_vwpmgeuoucadxk58xxyt\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\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 tinytable_s9wfml8sl6w07x3vpglf\n \n \n \n \n \n\n \n \n \n \n \n \n Thing\n Citation\n \n \n \n \n \n \n \n \n \n \n \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 tinytable_tkwcv196f0jyrcz3jja5\n \n \n \n \n \n\n \n \n \n \n \n \n Thing\n Citation\n \n \n \n \n \n \n \n \n \n \n \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 tinytable_kqgav0azp3b8n6eaw0f1\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\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 tinytable_ya0whhpcepp3fg1o9rkb\n \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 1972-08-03\n True \n \n \n 201399\n 201.4 \n 1971-06-10\n True \n \n \n 100188\n 0.13\n 1970-03-19\n False\n \n \n \n \n\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 tinytable_5kx6pzxuuwsqi3hm8fa3\n \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 August 03 1972\n True\n \n \n 201 399,18\n 201.4\n June 10 1971\n True\n \n \n 100 188,39\n 0.1\n March 19 1970\n False\n \n \n \n \n\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 tinytable_njeyeduglos52zaj3es6\n \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\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 tinytable_mudcqalo09029rrym1av\n \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\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 tinytable_dhbbxg7t0zf74pn7i3y6\n \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\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 tinytable_raglvjouralgseapuonj\n \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\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 tinytable_s0rwxv2oucjx9iubssmy\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 \n\n \n\n\n\ntt(tab) |> format_tt()\n\n \n\n \n \n \n tinytable_xtupgi89ycb7mt0jvi6e\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\n \n\n\n\ntt(tab) |> format_tt(replace = \"-\")\n\n \n\n \n \n \n tinytable_pzinpoepdfoo2pgxz4ib\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\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 tinytable_07ttjjstxh72pmeltemt\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\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 tinytable_cw3khercyr0a6dvvyzdc\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\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 tinytable_vq1glx30pwodcqutyctr\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\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 tinytable_eeghkpijyvsrwrhemiyi\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\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 tinytable_o79k7x3zi57wlca6whty\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\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 tinytable_o6p8muuka98snahy2hgz\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\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 tinytable_c6de5e4vfcv9x9cptcut\n \n \n \n \n \n\n \n \n \n \n \n \n Thing\n Citation\n \n \n \n \n \n \n \n \n \n \n \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 tinytable_bjujyq1zga0bfaifhmj5\n \n \n \n \n \n\n \n \n \n \n \n \n Thing\n Citation\n \n \n \n \n \n \n \n \n \n \n \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 tinytable_wk8vy50ctnm3ee6f3fa6\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\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",
@@ -594,7 +594,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 tinytable_6fxfmc8yiwp2bz0o2g5n\n \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-09-09\n True \n \n \n 201399\n 201.4 \n 1972-09-27\n True \n \n \n 100188\n 0.13\n 1970-05-10\n False\n \n \n \n \n\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 tinytable_j57ukfsng7a19s4dneoj\n \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 September 09 1971\n True\n \n \n 201 399,18\n 201.4\n September 27 1972\n True\n \n \n 100 188,39\n 0.1\n May 10 1970\n False\n \n \n \n \n\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 tinytable_7drb9moylxd2kx9pmvaa\n \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\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 tinytable_ya0whhpcepp3fg1o9rkb\n \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 1972-08-03\n True \n \n \n 201399\n 201.4 \n 1971-06-10\n True \n \n \n 100188\n 0.13\n 1970-03-19\n False\n \n \n \n \n\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 tinytable_5kx6pzxuuwsqi3hm8fa3\n \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 August 03 1972\n True\n \n \n 201 399,18\n 201.4\n June 10 1971\n True\n \n \n 100 188,39\n 0.1\n March 19 1970\n False\n \n \n \n \n\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 tinytable_njeyeduglos52zaj3es6\n \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\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",
@@ -606,7 +606,7 @@
"href": "vignettes/format.html#significant-digits-and-decimals",
"title": "Formatting",
"section": "",
- "text": "By 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 tinytable_ki99hrfy8a8mqlri9h0x\n \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\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 tinytable_3j2uc0mee8152dh67895\n \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\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 tinytable_adl4ehwmivgwh3wp6qe7\n \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",
+ "text": "By 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 tinytable_mudcqalo09029rrym1av\n \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\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 tinytable_dhbbxg7t0zf74pn7i3y6\n \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\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 tinytable_raglvjouralgseapuonj\n \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",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -618,7 +618,7 @@
"href": "vignettes/format.html#replacement",
"title": "Formatting",
"section": "",
- "text": "Missing 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 tinytable_0xszfelbkhjqs051awux\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 \n\n \n\n\n\ntt(tab) |> format_tt()\n\n \n\n \n \n \n tinytable_w3etbtsb7c9rusa3i2vb\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\n \n\n\n\ntt(tab) |> format_tt(replace = \"-\")\n\n \n\n \n \n \n tinytable_4zb2jhv6yu413z1yh0tx\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\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 tinytable_9thjshodw1t66m3u1gm0\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 ∞",
+ "text": "Missing 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 tinytable_s0rwxv2oucjx9iubssmy\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 \n\n \n\n\n\ntt(tab) |> format_tt()\n\n \n\n \n \n \n tinytable_xtupgi89ycb7mt0jvi6e\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\n \n\n\n\ntt(tab) |> format_tt(replace = \"-\")\n\n \n\n \n \n \n tinytable_pzinpoepdfoo2pgxz4ib\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\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 tinytable_07ttjjstxh72pmeltemt\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 ∞",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -630,7 +630,7 @@
"href": "vignettes/format.html#escape-special-characters",
"title": "Formatting",
"section": "",
- "text": "LaTeX 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 tinytable_x77dgundaipxuftz6658\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\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 \\\\$\"",
+ "text": "LaTeX 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 tinytable_cw3khercyr0a6dvvyzdc\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\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 \\\\$\"",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -642,7 +642,7 @@
"href": "vignettes/format.html#markdown",
"title": "Formatting",
"section": "",
- "text": "Markdown 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 tinytable_tldwof2xz3yatnu1bfcw\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\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 tinytable_295fmu5lmillx49gx8d7\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",
+ "text": "Markdown 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 tinytable_vq1glx30pwodcqutyctr\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\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 tinytable_eeghkpijyvsrwrhemiyi\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",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -654,7 +654,7 @@
"href": "vignettes/format.html#custom-functions",
"title": "Formatting",
"section": "",
- "text": "On 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 tinytable_8iuc2w6mh3mrs6lu28tm\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\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 tinytable_vwpmgeuoucadxk58xxyt\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%",
+ "text": "On 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 tinytable_o79k7x3zi57wlca6whty\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\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 tinytable_o6p8muuka98snahy2hgz\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%",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -666,7 +666,7 @@
"href": "vignettes/format.html#quarto-data-processing",
"title": "Formatting",
"section": "",
- "text": "Quarto 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 tinytable_s9wfml8sl6w07x3vpglf\n \n \n \n \n \n\n \n \n \n \n \n \n Thing\n Citation\n \n \n \n \n \n \n \n \n \n \n \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 tinytable_tkwcv196f0jyrcz3jja5\n \n \n \n \n \n\n \n \n \n \n \n \n Thing\n Citation\n \n \n \n \n \n \n \n \n \n \n \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 tinytable_kqgav0azp3b8n6eaw0f1\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\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": "Quarto 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 tinytable_c6de5e4vfcv9x9cptcut\n \n \n \n \n \n\n \n \n \n \n \n \n Thing\n Citation\n \n \n \n \n \n \n \n \n \n \n \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 tinytable_bjujyq1zga0bfaifhmj5\n \n \n \n \n \n\n \n \n \n \n \n \n Thing\n Citation\n \n \n \n \n \n \n \n \n \n \n \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 tinytable_wk8vy50ctnm3ee6f3fa6\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\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",
@@ -678,7 +678,7 @@
"href": "vignettes/plot.html",
"title": "Plots and images",
"section": "",
- "text": "The plot_tt() function can embed images and plots in a tinytable. We can insert images by specifying their paths and positions (i/j).\n\nlibrary(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\nx <- mtcars[1:4, 1:5]\n\n\n\nTo insert images in a table, we use the plot_tt() function. The path_img values must be relative to the main document saved by save_tt() or to the Quarto (or Rmarkdown) document in which the code is executed.\n\ndat <- data.frame(\n Species = c(\"Spider\", \"Squirrel\"),\n Image = \"\"\n)\n\nimg <- c(\n \"../figures/spider.png\",\n \"../figures/squirrel.png\"\n)\n\ntt(dat) |>\n plot_tt(j = 2, images = img, height = 3)\n\n \n\n \n \n \n tinytable_1puu812ebouus3783vnz\n \n \n \n \n \n\n \n \n \n \n \n \n Species\n Image\n \n \n \n \n \n Spider \n \n \n \n Squirrel\n \n \n \n \n \n\n \n\n \n\n\n\n\nIn HTML tables, it is possible to insert tables directly from a web address, but not in LaTeX.\n\ndat <- data.frame(\"R\" = \"\")\nimg <- \"https://cran.r-project.org/Rlogo.svg\"\ntt(dat) |>\n plot_tt(i = 1, j = 1, images = img, height = 7) |>\n style_tt(j = 1, align = \"c\")\n\n \n\n \n \n \n tinytable_du8vtlaumx83961ljmop\n \n \n \n \n \n\n \n \n \n \n \n \n R\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nWe can draw inline plots three ways, with\n\nBuilt-in templates for histograms, density plots, and bar plots\nCustom plots using base R plots.\nCustom plots using ggplot2.\n\nTo draw custom plots, one simply has to define a custom function, whose structure we illustrate below.\n\n\nThere are several types of inline plots available by default. For example,\n\nplot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)\n\ndat <- data.frame(\n Variables = c(\"mpg\", \"hp\", \"qsec\"), \n Histogram = \"\",\n Density = \"\",\n Bar = \"\",\n Line = \"\"\n)\n\n# random data for sparklines\nlines <- lapply(1:3, \\(x) data.frame(x = 1:10, y = rnorm(10)))\n\ntt(dat) |>\n plot_tt(j = 2, fun = \"histogram\", data = plot_data) |>\n plot_tt(j = 3, fun = \"density\", data = plot_data, color = \"darkgreen\") |>\n plot_tt(j = 4, fun = \"bar\", data = list(2, 3, 6), color = \"orange\") |>\n plot_tt(j = 5, fun = \"line\", data = lines, color = \"blue\") |>\n style_tt(j = 2:5, align = \"c\")\n\n \n\n \n \n \n tinytable_cir87k17779pc6xx0wd8\n \n \n \n \n \n\n \n \n \n \n \n \n Variables\n Histogram\n Density\n Bar\n Line\n \n \n \n \n \n mpg \n \n \n \n \n \n \n hp \n \n \n \n \n \n \n qsec\n \n \n \n \n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nImportant: Custom functions must have ... as an argument.\nTo create a custom inline plot using Base R plotting functions, we create a function that returns another function. tinytable will then call that second function internally to generate the plot.\nThis is easier than it sounds! For example:\n\nf <- function(d, ...) {\n function() hist(d, axes = FALSE, ann = FALSE, col = \"lightblue\")\n}\n\nplot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)\n\ndat <- data.frame(Variables = c(\"mpg\", \"hp\", \"qsec\"), Histogram = \"\")\n\ntt(dat) |>\n plot_tt(j = 2, fun = f, data = plot_data)\n\n \n\n \n \n \n tinytable_5jpsbg07nqy01s6hvskq\n \n \n \n \n \n\n \n \n \n \n \n \n Variables\n Histogram\n \n \n \n \n \n mpg \n \n \n \n hp \n \n \n \n qsec\n \n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nImportant: Custom functions must have ... as an argument.\nTo create a custom inline plot using ggplot2, we create a function that returns a ggplot object:\n\nlibrary(ggplot2)\n\nf <- function(d, color = \"black\", ...) {\n d <- data.frame(x = d)\n ggplot(d, aes(x = x)) + \n geom_histogram(bins = 30, color = color, fill = color) +\n scale_x_continuous(expand=c(0,0)) +\n scale_y_continuous(expand=c(0,0)) +\n theme_void()\n}\n\nplot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)\n\ntt(dat) |>\n plot_tt(j = 2, fun = f, data = plot_data, color = \"pink\")\n\n \n\n \n \n \n tinytable_hiz988byoiqzy2oaidww\n \n \n \n \n \n\n \n \n \n \n \n \n Variables\n Histogram\n \n \n \n \n \n mpg \n \n \n \n hp \n \n \n \n qsec\n \n \n \n \n \n\n \n\n \n\n\n\n\nWe can insert arbitrarily complex plots by customizing the ggplot2 call:\n\npenguins <- read.csv(\n \"https://vincentarelbundock.github.io/Rdatasets/csv/palmerpenguins/penguins.csv\",\n na.strings = \"\") |> na.omit()\n\n# split data by species\ndat <- split(penguins, penguins$species)\nbody <- lapply(dat, \\(x) x$body_mass_g)\nflip <- lapply(dat, \\(x) x$flipper_length_mm)\n\n# create nearly empty table\ntab <- data.frame(\n \"Species\" = names(dat),\n \"Body Mass\" = \"\",\n \"Flipper Length\" = \"\",\n \"Body vs. Flipper\" = \"\",\n check.names = FALSE\n)\n\n# custom ggplot2 function to create inline plot\nf <- function(d, ...) {\n ggplot(d, aes(x = flipper_length_mm, y = body_mass_g, color = sex)) +\n geom_point(size = .2) +\n scale_x_continuous(expand=c(0,0)) +\n scale_y_continuous(expand=c(0,0)) +\n scale_color_manual(values = c(\"#E69F00\", \"#56B4E9\")) +\n theme_void() +\n theme(legend.position = \"none\")\n}\n\n# `tinytable` calls\ntt(tab) |>\n plot_tt(j = 2, fun = \"histogram\", data = body, height = 2) |>\n plot_tt(j = 3, fun = \"density\", data = flip, height = 2) |>\n plot_tt(j = 4, fun = f, data = dat, height = 2) |>\n style_tt(j = 2:4, align = \"c\") \n\n \n\n \n \n \n tinytable_dox1gp6830bb5x2sj1mz\n \n \n \n \n \n\n \n \n \n \n \n \n Species\n Body Mass\n Flipper Length\n Body vs. Flipper\n \n \n \n \n \n Adelie \n \n \n \n \n \n Chinstrap\n \n \n \n \n \n Gentoo \n \n \n \n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\n\nWe can use the fontawesome package to include fancy icons in HTML tables:\n\nlibrary(fontawesome)\ntmp <- mtcars[1:4, 1:4]\ntmp[1, 1] <- paste(fa(\"r-project\"), \"for statistics\")\ntt(tmp)\n\n \n\n \n \n \n tinytable_z4vxow8clatxtcy6t4xo\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n for statistics\n 6\n 160\n 110\n \n \n 21 \n 6\n 160\n 110\n \n \n 22.8 \n 4\n 108\n 93\n \n \n 21.4 \n 6\n 258\n 110",
+ "text": "The plot_tt() function can embed images and plots in a tinytable. We can insert images by specifying their paths and positions (i/j).\n\nlibrary(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\nx <- mtcars[1:4, 1:5]\n\n\n\nTo insert images in a table, we use the plot_tt() function. The path_img values must be relative to the main document saved by save_tt() or to the Quarto (or Rmarkdown) document in which the code is executed.\n\ndat <- data.frame(\n Species = c(\"Spider\", \"Squirrel\"),\n Image = \"\"\n)\n\nimg <- c(\n \"../figures/spider.png\",\n \"../figures/squirrel.png\"\n)\n\ntt(dat) |>\n plot_tt(j = 2, images = img, height = 3)\n\n \n\n \n \n \n tinytable_io8xba8tvaa450tshnds\n \n \n \n \n \n\n \n \n \n \n \n \n Species\n Image\n \n \n \n \n \n Spider \n \n \n \n Squirrel\n \n \n \n \n \n\n \n\n \n\n\n\n\nIn HTML tables, it is possible to insert tables directly from a web address, but not in LaTeX.\n\ndat <- data.frame(\"R\" = \"\")\nimg <- \"https://cran.r-project.org/Rlogo.svg\"\ntt(dat) |>\n plot_tt(i = 1, j = 1, images = img, height = 7) |>\n style_tt(j = 1, align = \"c\")\n\n \n\n \n \n \n tinytable_5vvumc9q3zw6pnnvg6ra\n \n \n \n \n \n\n \n \n \n \n \n \n R\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nWe can draw inline plots three ways, with\n\nBuilt-in templates for histograms, density plots, and bar plots\nCustom plots using base R plots.\nCustom plots using ggplot2.\n\nTo draw custom plots, one simply has to define a custom function, whose structure we illustrate below.\n\n\nThere are several types of inline plots available by default. For example,\n\nplot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)\n\ndat <- data.frame(\n Variables = c(\"mpg\", \"hp\", \"qsec\"), \n Histogram = \"\",\n Density = \"\",\n Bar = \"\",\n Line = \"\"\n)\n\n# random data for sparklines\nlines <- lapply(1:3, \\(x) data.frame(x = 1:10, y = rnorm(10)))\n\ntt(dat) |>\n plot_tt(j = 2, fun = \"histogram\", data = plot_data) |>\n plot_tt(j = 3, fun = \"density\", data = plot_data, color = \"darkgreen\") |>\n plot_tt(j = 4, fun = \"bar\", data = list(2, 3, 6), color = \"orange\") |>\n plot_tt(j = 5, fun = \"line\", data = lines, color = \"blue\") |>\n style_tt(j = 2:5, align = \"c\")\n\n \n\n \n \n \n tinytable_0rpvexstgblsw8fzj55u\n \n \n \n \n \n\n \n \n \n \n \n \n Variables\n Histogram\n Density\n Bar\n Line\n \n \n \n \n \n mpg \n \n \n \n \n \n \n hp \n \n \n \n \n \n \n qsec\n \n \n \n \n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nImportant: Custom functions must have ... as an argument.\nTo create a custom inline plot using Base R plotting functions, we create a function that returns another function. tinytable will then call that second function internally to generate the plot.\nThis is easier than it sounds! For example:\n\nf <- function(d, ...) {\n function() hist(d, axes = FALSE, ann = FALSE, col = \"lightblue\")\n}\n\nplot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)\n\ndat <- data.frame(Variables = c(\"mpg\", \"hp\", \"qsec\"), Histogram = \"\")\n\ntt(dat) |>\n plot_tt(j = 2, fun = f, data = plot_data)\n\n \n\n \n \n \n tinytable_wxihn2y3pl937d67dkhs\n \n \n \n \n \n\n \n \n \n \n \n \n Variables\n Histogram\n \n \n \n \n \n mpg \n \n \n \n hp \n \n \n \n qsec\n \n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nImportant: Custom functions must have ... as an argument.\nTo create a custom inline plot using ggplot2, we create a function that returns a ggplot object:\n\nlibrary(ggplot2)\n\nf <- function(d, color = \"black\", ...) {\n d <- data.frame(x = d)\n ggplot(d, aes(x = x)) + \n geom_histogram(bins = 30, color = color, fill = color) +\n scale_x_continuous(expand=c(0,0)) +\n scale_y_continuous(expand=c(0,0)) +\n theme_void()\n}\n\nplot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)\n\ntt(dat) |>\n plot_tt(j = 2, fun = f, data = plot_data, color = \"pink\")\n\n \n\n \n \n \n tinytable_g56q7hkr7h2i3bx47yx2\n \n \n \n \n \n\n \n \n \n \n \n \n Variables\n Histogram\n \n \n \n \n \n mpg \n \n \n \n hp \n \n \n \n qsec\n \n \n \n \n \n\n \n\n \n\n\n\n\nWe can insert arbitrarily complex plots by customizing the ggplot2 call:\n\npenguins <- read.csv(\n \"https://vincentarelbundock.github.io/Rdatasets/csv/palmerpenguins/penguins.csv\",\n na.strings = \"\") |> na.omit()\n\n# split data by species\ndat <- split(penguins, penguins$species)\nbody <- lapply(dat, \\(x) x$body_mass_g)\nflip <- lapply(dat, \\(x) x$flipper_length_mm)\n\n# create nearly empty table\ntab <- data.frame(\n \"Species\" = names(dat),\n \"Body Mass\" = \"\",\n \"Flipper Length\" = \"\",\n \"Body vs. Flipper\" = \"\",\n check.names = FALSE\n)\n\n# custom ggplot2 function to create inline plot\nf <- function(d, ...) {\n ggplot(d, aes(x = flipper_length_mm, y = body_mass_g, color = sex)) +\n geom_point(size = .2) +\n scale_x_continuous(expand=c(0,0)) +\n scale_y_continuous(expand=c(0,0)) +\n scale_color_manual(values = c(\"#E69F00\", \"#56B4E9\")) +\n theme_void() +\n theme(legend.position = \"none\")\n}\n\n# `tinytable` calls\ntt(tab) |>\n plot_tt(j = 2, fun = \"histogram\", data = body, height = 2) |>\n plot_tt(j = 3, fun = \"density\", data = flip, height = 2) |>\n plot_tt(j = 4, fun = f, data = dat, height = 2) |>\n style_tt(j = 2:4, align = \"c\") \n\n \n\n \n \n \n tinytable_2bn6o2elk6s53z3dmsvo\n \n \n \n \n \n\n \n \n \n \n \n \n Species\n Body Mass\n Flipper Length\n Body vs. Flipper\n \n \n \n \n \n Adelie \n \n \n \n \n \n Chinstrap\n \n \n \n \n \n Gentoo \n \n \n \n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\n\nWe can use the fontawesome package to include fancy icons in HTML tables:\n\nlibrary(fontawesome)\ntmp <- mtcars[1:4, 1:4]\ntmp[1, 1] <- paste(fa(\"r-project\"), \"for statistics\")\ntt(tmp)\n\n \n\n \n \n \n tinytable_80ez3yv4yz8aqao7rjcq\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n for statistics\n 6\n 160\n 110\n \n \n 21 \n 6\n 160\n 110\n \n \n 22.8 \n 4\n 108\n 93\n \n \n 21.4 \n 6\n 258\n 110",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -690,7 +690,7 @@
"href": "vignettes/plot.html#inserting-images-in-tables",
"title": "Plots and images",
"section": "",
- "text": "To insert images in a table, we use the plot_tt() function. The path_img values must be relative to the main document saved by save_tt() or to the Quarto (or Rmarkdown) document in which the code is executed.\n\ndat <- data.frame(\n Species = c(\"Spider\", \"Squirrel\"),\n Image = \"\"\n)\n\nimg <- c(\n \"../figures/spider.png\",\n \"../figures/squirrel.png\"\n)\n\ntt(dat) |>\n plot_tt(j = 2, images = img, height = 3)\n\n \n\n \n \n \n tinytable_1puu812ebouus3783vnz\n \n \n \n \n \n\n \n \n \n \n \n \n Species\n Image\n \n \n \n \n \n Spider \n \n \n \n Squirrel\n \n \n \n \n \n\n \n\n \n\n\n\n\nIn HTML tables, it is possible to insert tables directly from a web address, but not in LaTeX.\n\ndat <- data.frame(\"R\" = \"\")\nimg <- \"https://cran.r-project.org/Rlogo.svg\"\ntt(dat) |>\n plot_tt(i = 1, j = 1, images = img, height = 7) |>\n style_tt(j = 1, align = \"c\")\n\n \n\n \n \n \n tinytable_du8vtlaumx83961ljmop\n \n \n \n \n \n\n \n \n \n \n \n \n R",
+ "text": "To insert images in a table, we use the plot_tt() function. The path_img values must be relative to the main document saved by save_tt() or to the Quarto (or Rmarkdown) document in which the code is executed.\n\ndat <- data.frame(\n Species = c(\"Spider\", \"Squirrel\"),\n Image = \"\"\n)\n\nimg <- c(\n \"../figures/spider.png\",\n \"../figures/squirrel.png\"\n)\n\ntt(dat) |>\n plot_tt(j = 2, images = img, height = 3)\n\n \n\n \n \n \n tinytable_io8xba8tvaa450tshnds\n \n \n \n \n \n\n \n \n \n \n \n \n Species\n Image\n \n \n \n \n \n Spider \n \n \n \n Squirrel\n \n \n \n \n \n\n \n\n \n\n\n\n\nIn HTML tables, it is possible to insert tables directly from a web address, but not in LaTeX.\n\ndat <- data.frame(\"R\" = \"\")\nimg <- \"https://cran.r-project.org/Rlogo.svg\"\ntt(dat) |>\n plot_tt(i = 1, j = 1, images = img, height = 7) |>\n style_tt(j = 1, align = \"c\")\n\n \n\n \n \n \n tinytable_5vvumc9q3zw6pnnvg6ra\n \n \n \n \n \n\n \n \n \n \n \n \n R",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -702,7 +702,7 @@
"href": "vignettes/plot.html#inline-plots",
"title": "Plots and images",
"section": "",
- "text": "We can draw inline plots three ways, with\n\nBuilt-in templates for histograms, density plots, and bar plots\nCustom plots using base R plots.\nCustom plots using ggplot2.\n\nTo draw custom plots, one simply has to define a custom function, whose structure we illustrate below.\n\n\nThere are several types of inline plots available by default. For example,\n\nplot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)\n\ndat <- data.frame(\n Variables = c(\"mpg\", \"hp\", \"qsec\"), \n Histogram = \"\",\n Density = \"\",\n Bar = \"\",\n Line = \"\"\n)\n\n# random data for sparklines\nlines <- lapply(1:3, \\(x) data.frame(x = 1:10, y = rnorm(10)))\n\ntt(dat) |>\n plot_tt(j = 2, fun = \"histogram\", data = plot_data) |>\n plot_tt(j = 3, fun = \"density\", data = plot_data, color = \"darkgreen\") |>\n plot_tt(j = 4, fun = \"bar\", data = list(2, 3, 6), color = \"orange\") |>\n plot_tt(j = 5, fun = \"line\", data = lines, color = \"blue\") |>\n style_tt(j = 2:5, align = \"c\")\n\n \n\n \n \n \n tinytable_cir87k17779pc6xx0wd8\n \n \n \n \n \n\n \n \n \n \n \n \n Variables\n Histogram\n Density\n Bar\n Line\n \n \n \n \n \n mpg \n \n \n \n \n \n \n hp \n \n \n \n \n \n \n qsec\n \n \n \n \n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nImportant: Custom functions must have ... as an argument.\nTo create a custom inline plot using Base R plotting functions, we create a function that returns another function. tinytable will then call that second function internally to generate the plot.\nThis is easier than it sounds! For example:\n\nf <- function(d, ...) {\n function() hist(d, axes = FALSE, ann = FALSE, col = \"lightblue\")\n}\n\nplot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)\n\ndat <- data.frame(Variables = c(\"mpg\", \"hp\", \"qsec\"), Histogram = \"\")\n\ntt(dat) |>\n plot_tt(j = 2, fun = f, data = plot_data)\n\n \n\n \n \n \n tinytable_5jpsbg07nqy01s6hvskq\n \n \n \n \n \n\n \n \n \n \n \n \n Variables\n Histogram\n \n \n \n \n \n mpg \n \n \n \n hp \n \n \n \n qsec\n \n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nImportant: Custom functions must have ... as an argument.\nTo create a custom inline plot using ggplot2, we create a function that returns a ggplot object:\n\nlibrary(ggplot2)\n\nf <- function(d, color = \"black\", ...) {\n d <- data.frame(x = d)\n ggplot(d, aes(x = x)) + \n geom_histogram(bins = 30, color = color, fill = color) +\n scale_x_continuous(expand=c(0,0)) +\n scale_y_continuous(expand=c(0,0)) +\n theme_void()\n}\n\nplot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)\n\ntt(dat) |>\n plot_tt(j = 2, fun = f, data = plot_data, color = \"pink\")\n\n \n\n \n \n \n tinytable_hiz988byoiqzy2oaidww\n \n \n \n \n \n\n \n \n \n \n \n \n Variables\n Histogram\n \n \n \n \n \n mpg \n \n \n \n hp \n \n \n \n qsec\n \n \n \n \n \n\n \n\n \n\n\n\n\nWe can insert arbitrarily complex plots by customizing the ggplot2 call:\n\npenguins <- read.csv(\n \"https://vincentarelbundock.github.io/Rdatasets/csv/palmerpenguins/penguins.csv\",\n na.strings = \"\") |> na.omit()\n\n# split data by species\ndat <- split(penguins, penguins$species)\nbody <- lapply(dat, \\(x) x$body_mass_g)\nflip <- lapply(dat, \\(x) x$flipper_length_mm)\n\n# create nearly empty table\ntab <- data.frame(\n \"Species\" = names(dat),\n \"Body Mass\" = \"\",\n \"Flipper Length\" = \"\",\n \"Body vs. Flipper\" = \"\",\n check.names = FALSE\n)\n\n# custom ggplot2 function to create inline plot\nf <- function(d, ...) {\n ggplot(d, aes(x = flipper_length_mm, y = body_mass_g, color = sex)) +\n geom_point(size = .2) +\n scale_x_continuous(expand=c(0,0)) +\n scale_y_continuous(expand=c(0,0)) +\n scale_color_manual(values = c(\"#E69F00\", \"#56B4E9\")) +\n theme_void() +\n theme(legend.position = \"none\")\n}\n\n# `tinytable` calls\ntt(tab) |>\n plot_tt(j = 2, fun = \"histogram\", data = body, height = 2) |>\n plot_tt(j = 3, fun = \"density\", data = flip, height = 2) |>\n plot_tt(j = 4, fun = f, data = dat, height = 2) |>\n style_tt(j = 2:4, align = \"c\") \n\n \n\n \n \n \n tinytable_dox1gp6830bb5x2sj1mz\n \n \n \n \n \n\n \n \n \n \n \n \n Species\n Body Mass\n Flipper Length\n Body vs. Flipper\n \n \n \n \n \n Adelie \n \n \n \n \n \n Chinstrap\n \n \n \n \n \n Gentoo",
+ "text": "We can draw inline plots three ways, with\n\nBuilt-in templates for histograms, density plots, and bar plots\nCustom plots using base R plots.\nCustom plots using ggplot2.\n\nTo draw custom plots, one simply has to define a custom function, whose structure we illustrate below.\n\n\nThere are several types of inline plots available by default. For example,\n\nplot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)\n\ndat <- data.frame(\n Variables = c(\"mpg\", \"hp\", \"qsec\"), \n Histogram = \"\",\n Density = \"\",\n Bar = \"\",\n Line = \"\"\n)\n\n# random data for sparklines\nlines <- lapply(1:3, \\(x) data.frame(x = 1:10, y = rnorm(10)))\n\ntt(dat) |>\n plot_tt(j = 2, fun = \"histogram\", data = plot_data) |>\n plot_tt(j = 3, fun = \"density\", data = plot_data, color = \"darkgreen\") |>\n plot_tt(j = 4, fun = \"bar\", data = list(2, 3, 6), color = \"orange\") |>\n plot_tt(j = 5, fun = \"line\", data = lines, color = \"blue\") |>\n style_tt(j = 2:5, align = \"c\")\n\n \n\n \n \n \n tinytable_0rpvexstgblsw8fzj55u\n \n \n \n \n \n\n \n \n \n \n \n \n Variables\n Histogram\n Density\n Bar\n Line\n \n \n \n \n \n mpg \n \n \n \n \n \n \n hp \n \n \n \n \n \n \n qsec\n \n \n \n \n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nImportant: Custom functions must have ... as an argument.\nTo create a custom inline plot using Base R plotting functions, we create a function that returns another function. tinytable will then call that second function internally to generate the plot.\nThis is easier than it sounds! For example:\n\nf <- function(d, ...) {\n function() hist(d, axes = FALSE, ann = FALSE, col = \"lightblue\")\n}\n\nplot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)\n\ndat <- data.frame(Variables = c(\"mpg\", \"hp\", \"qsec\"), Histogram = \"\")\n\ntt(dat) |>\n plot_tt(j = 2, fun = f, data = plot_data)\n\n \n\n \n \n \n tinytable_wxihn2y3pl937d67dkhs\n \n \n \n \n \n\n \n \n \n \n \n \n Variables\n Histogram\n \n \n \n \n \n mpg \n \n \n \n hp \n \n \n \n qsec\n \n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nImportant: Custom functions must have ... as an argument.\nTo create a custom inline plot using ggplot2, we create a function that returns a ggplot object:\n\nlibrary(ggplot2)\n\nf <- function(d, color = \"black\", ...) {\n d <- data.frame(x = d)\n ggplot(d, aes(x = x)) + \n geom_histogram(bins = 30, color = color, fill = color) +\n scale_x_continuous(expand=c(0,0)) +\n scale_y_continuous(expand=c(0,0)) +\n theme_void()\n}\n\nplot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)\n\ntt(dat) |>\n plot_tt(j = 2, fun = f, data = plot_data, color = \"pink\")\n\n \n\n \n \n \n tinytable_g56q7hkr7h2i3bx47yx2\n \n \n \n \n \n\n \n \n \n \n \n \n Variables\n Histogram\n \n \n \n \n \n mpg \n \n \n \n hp \n \n \n \n qsec\n \n \n \n \n \n\n \n\n \n\n\n\n\nWe can insert arbitrarily complex plots by customizing the ggplot2 call:\n\npenguins <- read.csv(\n \"https://vincentarelbundock.github.io/Rdatasets/csv/palmerpenguins/penguins.csv\",\n na.strings = \"\") |> na.omit()\n\n# split data by species\ndat <- split(penguins, penguins$species)\nbody <- lapply(dat, \\(x) x$body_mass_g)\nflip <- lapply(dat, \\(x) x$flipper_length_mm)\n\n# create nearly empty table\ntab <- data.frame(\n \"Species\" = names(dat),\n \"Body Mass\" = \"\",\n \"Flipper Length\" = \"\",\n \"Body vs. Flipper\" = \"\",\n check.names = FALSE\n)\n\n# custom ggplot2 function to create inline plot\nf <- function(d, ...) {\n ggplot(d, aes(x = flipper_length_mm, y = body_mass_g, color = sex)) +\n geom_point(size = .2) +\n scale_x_continuous(expand=c(0,0)) +\n scale_y_continuous(expand=c(0,0)) +\n scale_color_manual(values = c(\"#E69F00\", \"#56B4E9\")) +\n theme_void() +\n theme(legend.position = \"none\")\n}\n\n# `tinytable` calls\ntt(tab) |>\n plot_tt(j = 2, fun = \"histogram\", data = body, height = 2) |>\n plot_tt(j = 3, fun = \"density\", data = flip, height = 2) |>\n plot_tt(j = 4, fun = f, data = dat, height = 2) |>\n style_tt(j = 2:4, align = \"c\") \n\n \n\n \n \n \n tinytable_2bn6o2elk6s53z3dmsvo\n \n \n \n \n \n\n \n \n \n \n \n \n Species\n Body Mass\n Flipper Length\n Body vs. Flipper\n \n \n \n \n \n Adelie \n \n \n \n \n \n Chinstrap\n \n \n \n \n \n Gentoo",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -714,7 +714,7 @@
"href": "vignettes/plot.html#fontawesome",
"title": "Plots and images",
"section": "",
- "text": "We can use the fontawesome package to include fancy icons in HTML tables:\n\nlibrary(fontawesome)\ntmp <- mtcars[1:4, 1:4]\ntmp[1, 1] <- paste(fa(\"r-project\"), \"for statistics\")\ntt(tmp)\n\n \n\n \n \n \n tinytable_z4vxow8clatxtcy6t4xo\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n for statistics\n 6\n 160\n 110\n \n \n 21 \n 6\n 160\n 110\n \n \n 22.8 \n 4\n 108\n 93\n \n \n 21.4 \n 6\n 258\n 110",
+ "text": "We can use the fontawesome package to include fancy icons in HTML tables:\n\nlibrary(fontawesome)\ntmp <- mtcars[1:4, 1:4]\ntmp[1, 1] <- paste(fa(\"r-project\"), \"for statistics\")\ntt(tmp)\n\n \n\n \n \n \n tinytable_80ez3yv4yz8aqao7rjcq\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n for statistics\n 6\n 160\n 110\n \n \n 21 \n 6\n 160\n 110\n \n \n 22.8 \n 4\n 108\n 93\n \n \n 21.4 \n 6\n 258\n 110",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -726,7 +726,7 @@
"href": "vignettes/theme.html",
"title": "Themes",
"section": "",
- "text": "tinytable offers a very flexible theming framwork, which includes a few basic visual looks, as well as other functions to apply collections of transformations to tinytable objects in a repeatable way. These themes can be applied by supplying a string or function to the theme argument in tt(). Alternatively, users can call the theme_tt() function.\nThe main difference between theme_tt() and the other options in package, is that whereas style_tt() and format_tt() aim to be output agnostic, theme_tt() supplies transformations that can be output-specific, and which can have their own sets of distinct arguments. See below for a few examples.\n\nlibrary(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\nx <- mtcars[1:4, 1:5]\n\n\n\nTo begin, let’s explore a few of the basic looks supplied by themes:\n\ntt(x, theme = \"striped\")\n\n \n\n \n \n \n tinytable_84uj2lr43atobjwa09w5\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x) |> theme_tt(\"striped\")\n\n \n\n \n \n \n tinytable_bjtkkkqyu9igqwayjrfd\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ntt(x, theme = \"grid\")\n\n \n\n \n \n \n tinytable_9xy6ttkkjp9buayby08w\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ntt(x, theme = \"bootstrap\")\n\n \n\n \n \n \n tinytable_f7lgihkrwpbd9s73xrju\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nUsers can also define their own themes to apply consistent visual tweaks to tables. For example, this defines a themeing function and sets a global option to apply it to all tables consistently:\n\ntheme_vincent <- function(x, ...) {\n out <- x |> \n style_tt(color = \"teal\") |>\n theme_tt(\"placement\")\n out@caption <- \"Always use the same caption.\"\n out@width <- .5\n return(out)\n}\n\noptions(tinytable_tt_theme = theme_vincent)\n\ntt(mtcars[1:2, 1:2])\n\n \n\n \n \n \n tinytable_w3unmpitotpbk8jil98e\n \n \n \n \n \n\n \n \n \n \n Always use the same caption.\n \n mpg\n cyl\n \n \n \n \n \n 21\n 6\n \n \n 21\n 6\n \n \n \n \n\n \n\n \n\n\n\ntt(mtcars[1:3, 1:3])\n\n \n\n \n \n \n tinytable_0bdhrxcxih66ov7hfwfs\n \n \n \n \n \n\n \n \n \n \n Always use the same caption.\n \n mpg\n cyl\n disp\n \n \n \n \n \n 21 \n 6\n 160\n \n \n 21 \n 6\n 160\n \n \n 22.8\n 4\n 108\n \n \n \n \n\n \n\n \n\n\n\noptions(tinytable_tt_theme = NULL)\n\n\n\n\nThe tabular theme is designed to provide a more “raw” table, without a floating table environment in LaTeX, and without CSS or Javascript in HTML.\n\ntt(x) |> theme_tt(\"tabular\") |> print(\"latex\")\n\n\\begin{tblr}[ %% tabularray outer open\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nmpg & cyl & disp & hp & drat \\\\ \\midrule %% TinyTableHeader\n21 & 6 & 160 & 110 & 3.9 \\\\\n21 & 6 & 160 & 110 & 3.9 \\\\\n22.8 & 4 & 108 & 93 & 3.85 \\\\\n21.4 & 6 & 258 & 110 & 3.08 \\\\\n\\bottomrule\n\\end{tblr} \n\n\n\n\n\nLaTeX only.\n\n\n\nLaTeX only.\n\n\n\nLaTeX only.",
+ "text": "tinytable offers a very flexible theming framwork, which includes a few basic visual looks, as well as other functions to apply collections of transformations to tinytable objects in a repeatable way. These themes can be applied by supplying a string or function to the theme argument in tt(). Alternatively, users can call the theme_tt() function.\nThe main difference between theme_tt() and the other options in package, is that whereas style_tt() and format_tt() aim to be output agnostic, theme_tt() supplies transformations that can be output-specific, and which can have their own sets of distinct arguments. See below for a few examples.\n\nlibrary(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\nx <- mtcars[1:4, 1:5]\n\n\n\nTo begin, let’s explore a few of the basic looks supplied by themes:\n\ntt(x, theme = \"striped\")\n\n \n\n \n \n \n tinytable_wn13dmj8ls10nlzum0g8\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x) |> theme_tt(\"striped\")\n\n \n\n \n \n \n tinytable_prs8l581p203g8yv1kud\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ntt(x, theme = \"grid\")\n\n \n\n \n \n \n tinytable_em03k6k2i8ccewbsuhlq\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ntt(x, theme = \"bootstrap\")\n\n \n\n \n \n \n tinytable_0t7syb50yajgkhtewaal\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nUsers can also define their own themes to apply consistent visual tweaks to tables. For example, this defines a themeing function and sets a global option to apply it to all tables consistently:\n\ntheme_vincent <- function(x, ...) {\n out <- x |> \n style_tt(color = \"teal\") |>\n theme_tt(\"placement\")\n out@caption <- \"Always use the same caption.\"\n out@width <- .5\n return(out)\n}\n\noptions(tinytable_tt_theme = theme_vincent)\n\ntt(mtcars[1:2, 1:2])\n\n \n\n \n \n \n tinytable_h02vinnza2oxssolb6yt\n \n \n \n \n \n\n \n \n \n \n Always use the same caption.\n \n mpg\n cyl\n \n \n \n \n \n 21\n 6\n \n \n 21\n 6\n \n \n \n \n\n \n\n \n\n\n\ntt(mtcars[1:3, 1:3])\n\n \n\n \n \n \n tinytable_fqrj9drx2cwm3uyl5gae\n \n \n \n \n \n\n \n \n \n \n Always use the same caption.\n \n mpg\n cyl\n disp\n \n \n \n \n \n 21 \n 6\n 160\n \n \n 21 \n 6\n 160\n \n \n 22.8\n 4\n 108\n \n \n \n \n\n \n\n \n\n\n\noptions(tinytable_tt_theme = NULL)\n\n\n\n\nThe tabular theme is designed to provide a more “raw” table, without a floating table environment in LaTeX, and without CSS or Javascript in HTML.\n\ntt(x) |> theme_tt(\"tabular\") |> print(\"latex\")\n\n\\begin{tblr}[ %% tabularray outer open\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nmpg & cyl & disp & hp & drat \\\\ \\midrule %% TinyTableHeader\n21 & 6 & 160 & 110 & 3.9 \\\\\n21 & 6 & 160 & 110 & 3.9 \\\\\n22.8 & 4 & 108 & 93 & 3.85 \\\\\n21.4 & 6 & 258 & 110 & 3.08 \\\\\n\\bottomrule\n\\end{tblr} \n\n\n\n\n\nLaTeX only.\n\n\n\nLaTeX only.\n\n\n\nLaTeX only.",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -738,7 +738,7 @@
"href": "vignettes/theme.html#visual-themes",
"title": "Themes",
"section": "",
- "text": "To begin, let’s explore a few of the basic looks supplied by themes:\n\ntt(x, theme = \"striped\")\n\n \n\n \n \n \n tinytable_84uj2lr43atobjwa09w5\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x) |> theme_tt(\"striped\")\n\n \n\n \n \n \n tinytable_bjtkkkqyu9igqwayjrfd\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ntt(x, theme = \"grid\")\n\n \n\n \n \n \n tinytable_9xy6ttkkjp9buayby08w\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ntt(x, theme = \"bootstrap\")\n\n \n\n \n \n \n tinytable_f7lgihkrwpbd9s73xrju\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
+ "text": "To begin, let’s explore a few of the basic looks supplied by themes:\n\ntt(x, theme = \"striped\")\n\n \n\n \n \n \n tinytable_wn13dmj8ls10nlzum0g8\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x) |> theme_tt(\"striped\")\n\n \n\n \n \n \n tinytable_prs8l581p203g8yv1kud\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ntt(x, theme = \"grid\")\n\n \n\n \n \n \n tinytable_em03k6k2i8ccewbsuhlq\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ntt(x, theme = \"bootstrap\")\n\n \n\n \n \n \n tinytable_0t7syb50yajgkhtewaal\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -750,7 +750,7 @@
"href": "vignettes/theme.html#custom-themes",
"title": "Themes",
"section": "",
- "text": "Users can also define their own themes to apply consistent visual tweaks to tables. For example, this defines a themeing function and sets a global option to apply it to all tables consistently:\n\ntheme_vincent <- function(x, ...) {\n out <- x |> \n style_tt(color = \"teal\") |>\n theme_tt(\"placement\")\n out@caption <- \"Always use the same caption.\"\n out@width <- .5\n return(out)\n}\n\noptions(tinytable_tt_theme = theme_vincent)\n\ntt(mtcars[1:2, 1:2])\n\n \n\n \n \n \n tinytable_w3unmpitotpbk8jil98e\n \n \n \n \n \n\n \n \n \n \n Always use the same caption.\n \n mpg\n cyl\n \n \n \n \n \n 21\n 6\n \n \n 21\n 6\n \n \n \n \n\n \n\n \n\n\n\ntt(mtcars[1:3, 1:3])\n\n \n\n \n \n \n tinytable_0bdhrxcxih66ov7hfwfs\n \n \n \n \n \n\n \n \n \n \n Always use the same caption.\n \n mpg\n cyl\n disp\n \n \n \n \n \n 21 \n 6\n 160\n \n \n 21 \n 6\n 160\n \n \n 22.8\n 4\n 108\n \n \n \n \n\n \n\n \n\n\n\noptions(tinytable_tt_theme = NULL)",
+ "text": "Users can also define their own themes to apply consistent visual tweaks to tables. For example, this defines a themeing function and sets a global option to apply it to all tables consistently:\n\ntheme_vincent <- function(x, ...) {\n out <- x |> \n style_tt(color = \"teal\") |>\n theme_tt(\"placement\")\n out@caption <- \"Always use the same caption.\"\n out@width <- .5\n return(out)\n}\n\noptions(tinytable_tt_theme = theme_vincent)\n\ntt(mtcars[1:2, 1:2])\n\n \n\n \n \n \n tinytable_h02vinnza2oxssolb6yt\n \n \n \n \n \n\n \n \n \n \n Always use the same caption.\n \n mpg\n cyl\n \n \n \n \n \n 21\n 6\n \n \n 21\n 6\n \n \n \n \n\n \n\n \n\n\n\ntt(mtcars[1:3, 1:3])\n\n \n\n \n \n \n tinytable_fqrj9drx2cwm3uyl5gae\n \n \n \n \n \n\n \n \n \n \n Always use the same caption.\n \n mpg\n cyl\n disp\n \n \n \n \n \n 21 \n 6\n 160\n \n \n 21 \n 6\n 160\n \n \n 22.8\n 4\n 108\n \n \n \n \n\n \n\n \n\n\n\noptions(tinytable_tt_theme = NULL)",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -810,7 +810,7 @@
"href": "vignettes/tinytable.html",
"title": "Tiny Tables",
"section": "",
- "text": "tinytable is a small but powerful R package to draw HTML, LaTeX, Word, PDF, Markdown, and Typst tables. The interface is minimalist, but it gives users direct and convenient access to powerful frameworks to create endlessly customizable tables.\nInstall the latest version from R-Universe or CRAN:\n\ninstall.packages(\"tinytable\",\n repos = c(\"https://vincentarelbundock.r-universe.dev\", \"https://cran.r-project.org\"))\n\nThis tutorial introduces the main functions of the package. It is also available as a single PDF document.\nLoad the library and set some global options:\n\nlibrary(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\n\nDraw a first table:\n\nx <- mtcars[1:4, 1:5]\ntt(x)\n\n \n\n \n \n \n tinytable_e0lmpgozh6z0p2jk5mik\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\nThe width arguments indicating what proportion of the line width the table should cover. This argument accepts a number between 0 and 1 to control the whole table width, or a vector of numeric values between 0 and 1, representing each column.\n\ntt(x, width = 0.5)\n\n \n\n \n \n \n tinytable_35sy37lmitsl5nwwdvrc\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ntt(x, width = 1)\n\n \n\n \n \n \n tinytable_s98izdyrie728a1393p6\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can control individual columns by supplying a vector. In that case, the sum of width elements determines the full table width. For example, this table takes 70% of available width, with the first column 3 times as large as the other ones.\n\ntt(x, width = c(.3, .1, .1, .1, .1))\n\n \n\n \n \n \n tinytable_c8mgfnuezpz599sj3h74\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen the sum of the width vector exceeds 1, it is automatically normalized to full-width. This is convenient when we only want to specify column width in relative terms:\n\ntt(x, width = c(3, 2, 1, 1, 1))\n\n \n\n \n \n \n tinytable_xnihqqv70xv18j50bdbu\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen specifying a table width, the text is automatically wrapped to appropriate size:\n\nlorem <- data.frame(\n Lorem = \"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\",\n Ipsum = \" Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos.\"\n)\n\ntt(lorem, width = 3/4)\n\n \n\n \n \n \n tinytable_a40mzngvd4favw2s5v6r\n \n \n \n \n \n\n \n \n \n \n \n \n Lorem\n Ipsum\n \n \n \n \n \n Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\n Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos.\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe notes argument accepts single strings or named lists of strings:\n\nn <- \"Fusce id ipsum consequat ante pellentesque iaculis eu a ipsum. Mauris id ex in nulla consectetur aliquam. In nec tempus diam. Aliquam arcu nibh, dapibus id ex vestibulum, feugiat consequat erat. Morbi feugiat dapibus malesuada. Quisque vel ullamcorper felis. Aenean a sem at nisi tempor pretium sit amet quis lacus.\"\n\ntt(lorem, notes = n, width = 1)\n\n \n\n \n \n \n tinytable_ag5juszxo16jaho46vus\n \n \n \n \n \n\n \n \n A full-width table with wrapped text in cells and a footnote.\n \n \n \n Lorem\n Ipsum\n \n \n Fusce id ipsum consequat ante pellentesque iaculis eu a ipsum. Mauris id ex in nulla consectetur aliquam. In nec tempus diam. Aliquam arcu nibh, dapibus id ex vestibulum, feugiat consequat erat. Morbi feugiat dapibus malesuada. Quisque vel ullamcorper felis. Aenean a sem at nisi tempor pretium sit amet quis lacus.\n \n \n Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\n Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos.\n \n \n \n \n\n \n\n \n\n\n\n\nWhen notes is a named list, the names are used as identifiers and displayed as superscripts:\n\ntt(x, notes = list(a = \"Blah.\", b = \"Blah blah.\"))\n\n \n\n \n \n \n tinytable_bm4d993g5ff1i1qwz0dr\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 a Blah.\nb Blah blah.\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also add markers in individual cells by providing coordinates:\n\ntt(x, notes = list(\n a = list(i = 0:1, j = 1, text = \"Blah.\"),\n b = \"Blah blah.\"\n )\n)\n\n \n\n \n \n \n tinytable_tn7rytyhbji68iixwjzb\n \n \n \n \n \n\n \n \n \n \n \n \n mpga\n cyl\n disp\n hp\n drat\n \n \n a Blah.\nb Blah blah.\n \n \n 21 a\n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nIn Quarto, one should always specify captions cross-references using chunk options, and should not use the caption argument. This is because Quarto automatically post-processes tables, and may introduce conflict with the captions inserted by tinytable. For example:\n@tbl-blah shows that...\n\n```{r}\n#| label: tbl-blah\n#| tbl-cap: \"Blah blah blah\"\nlibrary(tinytable)\ntt(mtcars[1:4, 1:4])\n```\nAnd here is the rendered version of the code chunk above:\nTable 1 shows that…\n\nlibrary(tinytable)\ntt(mtcars[1:4, 1:4])\n\n\n\nTable 1: Blah blah blah\n\n\n\n \n\n \n \n \n tinytable_5i8cbvifmqbv32w7pxv6\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n 21 \n 6\n 160\n 110\n \n \n 21 \n 6\n 160\n 110\n \n \n 22.8\n 4\n 108\n 93\n \n \n 21.4\n 6\n 258\n 110\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nOne exception to the injunction above is when rendering a Quarto document to LaTeX using theme_tt(\"multipage\")\". In that case, one must avoid using the Quarto chunk option, because these options trigger Quarto post-processing that will conflict with the longtblr environment used to split long tables across multiple pages.\nThe alternative is to use to refer to tables using standard LaTeX syntax: \\ref{tbl-ex-multipage}. Then, use the caption argument in tt() to specify both the label and the caption:\n\ntt(iris, caption = \"Example table.\\\\label{tbl-ex-multipage}\") |>\n theme_tt(\"multipage\")\n\nFor standalone tables in any format (i.e., outside Quarto), you can use the caption argument like so:\n\ntt(x, caption = \"Blah blah.\\\\label{tbl-blah}\")\n\n\n\n\nTo insert LaTeX-style mathematical expressions in a tinytable, we enclose the expression in dollar signs: $...$. The expression will then rendered as a mathematical expression by MathJax (for HTML), LaTeX, or Pandoc. Do not forget to double escape any backslashes.\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 tinytable_ymd7wuk2d0ghfcuhaw4m\n \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\n \n\n\n\n\n\n\n\nManual line breaks work sligthly different in LaTeX (PDF) or HTML. This table shows the two strategies. For HTML, we insert a <br> tag. For LaTeX, we wrap the string in curly braces {}, and then insert two (escaped) backslashes: \\\\\\\\\n\nd <- data.frame(\n \"{Sed ut \\\\\\\\ perspiciatis unde}\",\n \"dicta sunt<br> explicabo. Nemo\"\n) |> setNames(c(\"LaTeX line break\", \"HTML line break\"))\ntt(d, width = 1)\n\n \n\n \n \n \n tinytable_0mpevmurjydteylfrlg6\n \n \n \n \n \n\n \n \n \n \n \n \n LaTeX line break\n HTML line break\n \n \n \n \n \n {Sed ut \\\\ perspiciatis unde}\n dicta sunt explicabo. Nemo\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\ntinytable can produce tables in HTML, Word, Markdown, LaTeX, Typst, PDF, or PNG format. An appropriate output format for printing is automatically selected based on (1) whether the function is called interactively, (2) is called within RStudio, and (3) the output format of the Rmarkdown or Quarto document, if applicable. Alternatively, users can specify the print format in print() or by setting a global option:\n\ntt(x) |> print(\"markdown\")\ntt(x) |> print(\"html\")\ntt(x) |> print(\"latex\")\n\noptions(tinytable_print_output = \"markdown\")\n\nWith the save_tt() function, users can also save tables directly to PNG (images), PDF or Word documents, and to any of the basic formats. All we need to do is supply a valid file name with the appropriate extension (ex: .png, .html, .pdf, etc.):\ntt(x) |> save_tt(\"path/to/file.png\")\ntt(x) |> save_tt(\"path/to/file.pdf\")\ntt(x) |> save_tt(\"path/to/file.docx\")\ntt(x) |> save_tt(\"path/to/file.html\")\ntt(x) |> save_tt(\"path/to/file.tex\")\ntt(x) |> save_tt(\"path/to/file.md\")\nsave_tt() can also return a string with the table in it, for further processing in R. In the first case, the table is printed to console with cat(). In the second case, it returns as a single string as an R object.\n\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 print(\"markdown\")\n\n+------+-----+------+-----+------+\n| | Foo | Bar |\n+------+-----+------+-----+------+\n| mpg | cyl | disp | hp | drat |\n+======+=====+======+=====+======+\n| 21 | 6 | 160 | 110 | 3.9 |\n+------+-----+------+-----+------+\n| 21 | 6 | 160 | 110 | 3.9 |\n+------+-----+------+-----+------+\n| Hello |\n+------+-----+------+-----+------+\n| 22.8 | 4 | 108 | 93 | 3.85 |\n+------+-----+------+-----+------+\n| 21.4 | 6 | 258 | 110 | 3.08 |\n+------+-----+------+-----+------+\n| 18.7 | 8 | 360 | 175 | 3.15 |\n+------+-----+------+-----+------+\n| 18.1 | 6 | 225 | 105 | 2.76 |\n+------+-----+------+-----+------+\n| 14.3 | 8 | 360 | 245 | 3.21 |\n+------+-----+------+-----+------+\n| World |\n+------+-----+------+-----+------+\n| 24.4 | 4 | 147 | 62 | 3.69 |\n+------+-----+------+-----+------+\n| 22.8 | 4 | 141 | 95 | 3.92 |\n+------+-----+------+-----+------+\n| 19.2 | 6 | 168 | 123 | 3.92 |\n+------+-----+------+-----+------+ \n\n\n\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 save_tt(\"markdown\")\n\n[1] \"+------+-----+------+-----+------+\\n| | Foo | Bar |\\n+------+-----+------+-----+------+\\n| mpg | cyl | disp | hp | drat |\\n+======+=====+======+=====+======+\\n| 21 | 6 | 160 | 110 | 3.9 |\\n+------+-----+------+-----+------+\\n| 21 | 6 | 160 | 110 | 3.9 |\\n+------+-----+------+-----+------+\\n| Hello |\\n+------+-----+------+-----+------+\\n| 22.8 | 4 | 108 | 93 | 3.85 |\\n+------+-----+------+-----+------+\\n| 21.4 | 6 | 258 | 110 | 3.08 |\\n+------+-----+------+-----+------+\\n| 18.7 | 8 | 360 | 175 | 3.15 |\\n+------+-----+------+-----+------+\\n| 18.1 | 6 | 225 | 105 | 2.76 |\\n+------+-----+------+-----+------+\\n| 14.3 | 8 | 360 | 245 | 3.21 |\\n+------+-----+------+-----+------+\\n| World |\\n+------+-----+------+-----+------+\\n| 24.4 | 4 | 147 | 62 | 3.69 |\\n+------+-----+------+-----+------+\\n| 22.8 | 4 | 141 | 95 | 3.92 |\\n+------+-----+------+-----+------+\\n| 19.2 | 6 | 168 | 123 | 3.92 |\\n+------+-----+------+-----+------+\"\n\n\n\n\n\nTables can be explored, modified, and combined using many of the usual base R functions:\n\na <- tt(mtcars[1:2, 1:2])\na\n\n \n\n \n \n \n tinytable_pwc8s1ytmmau9vb15m29\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n \n \n \n \n \n 21\n 6\n \n \n 21\n 6\n \n \n \n \n\n \n\n \n\n\n\ndim(a)\n\n[1] 2 2\n\nncol(a)\n\n[1] 2\n\nnrow(a)\n\n[1] 2\n\ncolnames(a)\n\n[1] \"mpg\" \"cyl\"\n\n\nRename columns:\n\ncolnames(a) <- c(\"a\", \"b\")\na\n\n \n\n \n \n \n tinytable_3bic6igzgzd13h7z2ahu\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 21\n 6\n \n \n 21\n 6\n \n \n \n \n\n \n\n \n\n\n\n\nTables can be combined with the usual rbind() function:\n\na <- tt(mtcars[1:3, 1:2], caption = \"Combine two tiny tables.\")\nb <- tt(mtcars[4:5, 8:10]) \n\nrbind(a, b)\n\n \n\n \n \n \n tinytable_7lwu800gy2b5nlgg8noo\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n vs\n am\n gear\n \n \n \n \n 1 \n 0 \n 3 \n \n \n \n \n 0 \n 0 \n 3 \n \n \n \n \n\n \n\n \n\n\n\nrbind(a, b) |> format_tt(replace = \"\")\n\n \n\n \n \n \n tinytable_fa65dkoo7qy3p7hr9k8n\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21\n 6\n \n \n \n \n \n 21\n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n vs\n am\n gear\n \n \n \n \n 1\n 0\n 3\n \n \n \n \n 0\n 0\n 3\n \n \n \n \n\n \n\n \n\n\n\n\nThe rbind2() S4 method is slightly more flexible than rbind(), as it supports arguments headers and use.names.\nOmit y header:\n\nrbind2(a, b, headers = FALSE)\n\n \n\n \n \n \n tinytable_b82d2zj80wnrmaip5jwg\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n 1\n 0\n 3\n \n \n \n \n 0\n 0\n 3\n \n \n \n \n\n \n\n \n\n\n\n\nBind tables by position rather than column names:\n\nrbind2(a, b, use_names = FALSE)\n\n \n\n \n \n \n tinytable_g80lo2xt15nt0e52jorq\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n gear\n \n \n \n \n \n 21 \n 6 \n \n \n \n 21 \n 6 \n \n \n \n 22.8\n 4 \n \n \n \n vs \n am\n gear\n \n \n 1 \n 0 \n 3 \n \n \n 0 \n 0 \n 3",
+ "text": "tinytable is a small but powerful R package to draw HTML, LaTeX, Word, PDF, Markdown, and Typst tables. The interface is minimalist, but it gives users direct and convenient access to powerful frameworks to create endlessly customizable tables.\nInstall the latest version from R-Universe or CRAN:\n\ninstall.packages(\"tinytable\",\n repos = c(\"https://vincentarelbundock.r-universe.dev\", \"https://cran.r-project.org\"))\n\nThis tutorial introduces the main functions of the package. It is also available as a single PDF document.\nLoad the library and set some global options:\n\nlibrary(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\n\nDraw a first table:\n\nx <- mtcars[1:4, 1:5]\ntt(x)\n\n \n\n \n \n \n tinytable_ennpu3w44ie27h70uzvb\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\nThe width arguments indicating what proportion of the line width the table should cover. This argument accepts a number between 0 and 1 to control the whole table width, or a vector of numeric values between 0 and 1, representing each column.\n\ntt(x, width = 0.5)\n\n \n\n \n \n \n tinytable_keg89ludj1ezxv9pgsih\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ntt(x, width = 1)\n\n \n\n \n \n \n tinytable_ttkcslqete8v25k1h9u8\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can control individual columns by supplying a vector. In that case, the sum of width elements determines the full table width. For example, this table takes 70% of available width, with the first column 3 times as large as the other ones.\n\ntt(x, width = c(.3, .1, .1, .1, .1))\n\n \n\n \n \n \n tinytable_awbabfwmguq9gw7cr5m7\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen the sum of the width vector exceeds 1, it is automatically normalized to full-width. This is convenient when we only want to specify column width in relative terms:\n\ntt(x, width = c(3, 2, 1, 1, 1))\n\n \n\n \n \n \n tinytable_v5mbcr3wqz0o2oottx6g\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen specifying a table width, the text is automatically wrapped to appropriate size:\n\nlorem <- data.frame(\n Lorem = \"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\",\n Ipsum = \" Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos.\"\n)\n\ntt(lorem, width = 3/4)\n\n \n\n \n \n \n tinytable_148xv9rc0kwp2qsg84ti\n \n \n \n \n \n\n \n \n \n \n \n \n Lorem\n Ipsum\n \n \n \n \n \n Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\n Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos.\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe notes argument accepts single strings or named lists of strings:\n\nn <- \"Fusce id ipsum consequat ante pellentesque iaculis eu a ipsum. Mauris id ex in nulla consectetur aliquam. In nec tempus diam. Aliquam arcu nibh, dapibus id ex vestibulum, feugiat consequat erat. Morbi feugiat dapibus malesuada. Quisque vel ullamcorper felis. Aenean a sem at nisi tempor pretium sit amet quis lacus.\"\n\ntt(lorem, notes = n, width = 1)\n\n \n\n \n \n \n tinytable_podlc9wwdhgmg5mgk3ke\n \n \n \n \n \n\n \n \n A full-width table with wrapped text in cells and a footnote.\n \n \n \n Lorem\n Ipsum\n \n \n Fusce id ipsum consequat ante pellentesque iaculis eu a ipsum. Mauris id ex in nulla consectetur aliquam. In nec tempus diam. Aliquam arcu nibh, dapibus id ex vestibulum, feugiat consequat erat. Morbi feugiat dapibus malesuada. Quisque vel ullamcorper felis. Aenean a sem at nisi tempor pretium sit amet quis lacus.\n \n \n Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\n Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos.\n \n \n \n \n\n \n\n \n\n\n\n\nWhen notes is a named list, the names are used as identifiers and displayed as superscripts:\n\ntt(x, notes = list(a = \"Blah.\", b = \"Blah blah.\"))\n\n \n\n \n \n \n tinytable_pfvtd2nr809gnacpixdk\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 a Blah.\nb Blah blah.\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also add markers in individual cells by providing coordinates:\n\ntt(x, notes = list(\n a = list(i = 0:1, j = 1, text = \"Blah.\"),\n b = \"Blah blah.\"\n )\n)\n\n \n\n \n \n \n tinytable_h27mk848lc0mhz0r474k\n \n \n \n \n \n\n \n \n \n \n \n \n mpga\n cyl\n disp\n hp\n drat\n \n \n a Blah.\nb Blah blah.\n \n \n 21 a\n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nIn Quarto, one should always specify captions cross-references using chunk options, and should not use the caption argument. This is because Quarto automatically post-processes tables, and may introduce conflict with the captions inserted by tinytable. For example:\n@tbl-blah shows that...\n\n```{r}\n#| label: tbl-blah\n#| tbl-cap: \"Blah blah blah\"\nlibrary(tinytable)\ntt(mtcars[1:4, 1:4])\n```\nAnd here is the rendered version of the code chunk above:\nTable 1 shows that…\n\nlibrary(tinytable)\ntt(mtcars[1:4, 1:4])\n\n\n\nTable 1: Blah blah blah\n\n\n\n \n\n \n \n \n tinytable_j87t51w8kyftqmhjf3uc\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n 21 \n 6\n 160\n 110\n \n \n 21 \n 6\n 160\n 110\n \n \n 22.8\n 4\n 108\n 93\n \n \n 21.4\n 6\n 258\n 110\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nOne exception to the injunction above is when rendering a Quarto document to LaTeX using theme_tt(\"multipage\")\". In that case, one must avoid using the Quarto chunk option, because these options trigger Quarto post-processing that will conflict with the longtblr environment used to split long tables across multiple pages.\nThe alternative is to use to refer to tables using standard LaTeX syntax: \\ref{tbl-ex-multipage}. Then, use the caption argument in tt() to specify both the label and the caption:\n\ntt(iris, caption = \"Example table.\\\\label{tbl-ex-multipage}\") |>\n theme_tt(\"multipage\")\n\nFor standalone tables in any format (i.e., outside Quarto), you can use the caption argument like so:\n\ntt(x, caption = \"Blah blah.\\\\label{tbl-blah}\")\n\n\n\n\nTo insert LaTeX-style mathematical expressions in a tinytable, we enclose the expression in dollar signs: $...$. The expression will then rendered as a mathematical expression by MathJax (for HTML), LaTeX, or Pandoc. Do not forget to double escape any backslashes.\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 tinytable_18z19kklcybuo59jczbk\n \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\n \n\n\n\n\n\n\n\nManual line breaks work sligthly different in LaTeX (PDF) or HTML. This table shows the two strategies. For HTML, we insert a <br> tag. For LaTeX, we wrap the string in curly braces {}, and then insert two (escaped) backslashes: \\\\\\\\\n\nd <- data.frame(\n \"{Sed ut \\\\\\\\ perspiciatis unde}\",\n \"dicta sunt<br> explicabo. Nemo\"\n) |> setNames(c(\"LaTeX line break\", \"HTML line break\"))\ntt(d, width = 1)\n\n \n\n \n \n \n tinytable_tfay8lyisiqtkgl1k74b\n \n \n \n \n \n\n \n \n \n \n \n \n LaTeX line break\n HTML line break\n \n \n \n \n \n {Sed ut \\\\ perspiciatis unde}\n dicta sunt explicabo. Nemo\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\ntinytable can produce tables in HTML, Word, Markdown, LaTeX, Typst, PDF, or PNG format. An appropriate output format for printing is automatically selected based on (1) whether the function is called interactively, (2) is called within RStudio, and (3) the output format of the Rmarkdown or Quarto document, if applicable. Alternatively, users can specify the print format in print() or by setting a global option:\n\ntt(x) |> print(\"markdown\")\ntt(x) |> print(\"html\")\ntt(x) |> print(\"latex\")\n\noptions(tinytable_print_output = \"markdown\")\n\nWith the save_tt() function, users can also save tables directly to PNG (images), PDF or Word documents, and to any of the basic formats. All we need to do is supply a valid file name with the appropriate extension (ex: .png, .html, .pdf, etc.):\ntt(x) |> save_tt(\"path/to/file.png\")\ntt(x) |> save_tt(\"path/to/file.pdf\")\ntt(x) |> save_tt(\"path/to/file.docx\")\ntt(x) |> save_tt(\"path/to/file.html\")\ntt(x) |> save_tt(\"path/to/file.tex\")\ntt(x) |> save_tt(\"path/to/file.md\")\nsave_tt() can also return a string with the table in it, for further processing in R. In the first case, the table is printed to console with cat(). In the second case, it returns as a single string as an R object.\n\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 print(\"markdown\")\n\n+------+-----+------+-----+------+\n| | Foo | Bar |\n+------+-----+------+-----+------+\n| mpg | cyl | disp | hp | drat |\n+======+=====+======+=====+======+\n| 21 | 6 | 160 | 110 | 3.9 |\n+------+-----+------+-----+------+\n| 21 | 6 | 160 | 110 | 3.9 |\n+------+-----+------+-----+------+\n| Hello |\n+------+-----+------+-----+------+\n| 22.8 | 4 | 108 | 93 | 3.85 |\n+------+-----+------+-----+------+\n| 21.4 | 6 | 258 | 110 | 3.08 |\n+------+-----+------+-----+------+\n| 18.7 | 8 | 360 | 175 | 3.15 |\n+------+-----+------+-----+------+\n| 18.1 | 6 | 225 | 105 | 2.76 |\n+------+-----+------+-----+------+\n| 14.3 | 8 | 360 | 245 | 3.21 |\n+------+-----+------+-----+------+\n| World |\n+------+-----+------+-----+------+\n| 24.4 | 4 | 147 | 62 | 3.69 |\n+------+-----+------+-----+------+\n| 22.8 | 4 | 141 | 95 | 3.92 |\n+------+-----+------+-----+------+\n| 19.2 | 6 | 168 | 123 | 3.92 |\n+------+-----+------+-----+------+ \n\n\n\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 save_tt(\"markdown\")\n\n[1] \"+------+-----+------+-----+------+\\n| | Foo | Bar |\\n+------+-----+------+-----+------+\\n| mpg | cyl | disp | hp | drat |\\n+======+=====+======+=====+======+\\n| 21 | 6 | 160 | 110 | 3.9 |\\n+------+-----+------+-----+------+\\n| 21 | 6 | 160 | 110 | 3.9 |\\n+------+-----+------+-----+------+\\n| Hello |\\n+------+-----+------+-----+------+\\n| 22.8 | 4 | 108 | 93 | 3.85 |\\n+------+-----+------+-----+------+\\n| 21.4 | 6 | 258 | 110 | 3.08 |\\n+------+-----+------+-----+------+\\n| 18.7 | 8 | 360 | 175 | 3.15 |\\n+------+-----+------+-----+------+\\n| 18.1 | 6 | 225 | 105 | 2.76 |\\n+------+-----+------+-----+------+\\n| 14.3 | 8 | 360 | 245 | 3.21 |\\n+------+-----+------+-----+------+\\n| World |\\n+------+-----+------+-----+------+\\n| 24.4 | 4 | 147 | 62 | 3.69 |\\n+------+-----+------+-----+------+\\n| 22.8 | 4 | 141 | 95 | 3.92 |\\n+------+-----+------+-----+------+\\n| 19.2 | 6 | 168 | 123 | 3.92 |\\n+------+-----+------+-----+------+\"\n\n\n\n\n\nTables can be explored, modified, and combined using many of the usual base R functions:\n\na <- tt(mtcars[1:2, 1:2])\na\n\n \n\n \n \n \n tinytable_te288c4b64rjkg684rdi\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n \n \n \n \n \n 21\n 6\n \n \n 21\n 6\n \n \n \n \n\n \n\n \n\n\n\ndim(a)\n\n[1] 2 2\n\nncol(a)\n\n[1] 2\n\nnrow(a)\n\n[1] 2\n\ncolnames(a)\n\n[1] \"mpg\" \"cyl\"\n\n\nRename columns:\n\ncolnames(a) <- c(\"a\", \"b\")\na\n\n \n\n \n \n \n tinytable_ix93j4e72ae7nljruxvq\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 21\n 6\n \n \n 21\n 6\n \n \n \n \n\n \n\n \n\n\n\n\nTables can be combined with the usual rbind() function:\n\na <- tt(mtcars[1:3, 1:2], caption = \"Combine two tiny tables.\")\nb <- tt(mtcars[4:5, 8:10]) \n\nrbind(a, b)\n\n \n\n \n \n \n tinytable_vgipcv65p41fj15u0pua\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n vs\n am\n gear\n \n \n \n \n 1 \n 0 \n 3 \n \n \n \n \n 0 \n 0 \n 3 \n \n \n \n \n\n \n\n \n\n\n\nrbind(a, b) |> format_tt(replace = \"\")\n\n \n\n \n \n \n tinytable_n58taewpe4fik0ns36bg\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21\n 6\n \n \n \n \n \n 21\n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n vs\n am\n gear\n \n \n \n \n 1\n 0\n 3\n \n \n \n \n 0\n 0\n 3\n \n \n \n \n\n \n\n \n\n\n\n\nThe rbind2() S4 method is slightly more flexible than rbind(), as it supports arguments headers and use.names.\nOmit y header:\n\nrbind2(a, b, headers = FALSE)\n\n \n\n \n \n \n tinytable_w2wj4fuvrd9qml2r6dqg\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n 1\n 0\n 3\n \n \n \n \n 0\n 0\n 3\n \n \n \n \n\n \n\n \n\n\n\n\nBind tables by position rather than column names:\n\nrbind2(a, b, use_names = FALSE)\n\n \n\n \n \n \n tinytable_0kpsmer3h30he89vcqba\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n gear\n \n \n \n \n \n 21 \n 6 \n \n \n \n 21 \n 6 \n \n \n \n 22.8\n 4 \n \n \n \n vs \n am\n gear\n \n \n 1 \n 0 \n 3 \n \n \n 0 \n 0 \n 3",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -822,7 +822,7 @@
"href": "vignettes/tinytable.html#width",
"title": "Tiny Tables",
"section": "",
- "text": "The width arguments indicating what proportion of the line width the table should cover. This argument accepts a number between 0 and 1 to control the whole table width, or a vector of numeric values between 0 and 1, representing each column.\n\ntt(x, width = 0.5)\n\n \n\n \n \n \n tinytable_35sy37lmitsl5nwwdvrc\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ntt(x, width = 1)\n\n \n\n \n \n \n tinytable_s98izdyrie728a1393p6\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can control individual columns by supplying a vector. In that case, the sum of width elements determines the full table width. For example, this table takes 70% of available width, with the first column 3 times as large as the other ones.\n\ntt(x, width = c(.3, .1, .1, .1, .1))\n\n \n\n \n \n \n tinytable_c8mgfnuezpz599sj3h74\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen the sum of the width vector exceeds 1, it is automatically normalized to full-width. This is convenient when we only want to specify column width in relative terms:\n\ntt(x, width = c(3, 2, 1, 1, 1))\n\n \n\n \n \n \n tinytable_xnihqqv70xv18j50bdbu\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen specifying a table width, the text is automatically wrapped to appropriate size:\n\nlorem <- data.frame(\n Lorem = \"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\",\n Ipsum = \" Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos.\"\n)\n\ntt(lorem, width = 3/4)\n\n \n\n \n \n \n tinytable_a40mzngvd4favw2s5v6r\n \n \n \n \n \n\n \n \n \n \n \n \n Lorem\n Ipsum\n \n \n \n \n \n Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\n Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos.",
+ "text": "The width arguments indicating what proportion of the line width the table should cover. This argument accepts a number between 0 and 1 to control the whole table width, or a vector of numeric values between 0 and 1, representing each column.\n\ntt(x, width = 0.5)\n\n \n\n \n \n \n tinytable_keg89ludj1ezxv9pgsih\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ntt(x, width = 1)\n\n \n\n \n \n \n tinytable_ttkcslqete8v25k1h9u8\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can control individual columns by supplying a vector. In that case, the sum of width elements determines the full table width. For example, this table takes 70% of available width, with the first column 3 times as large as the other ones.\n\ntt(x, width = c(.3, .1, .1, .1, .1))\n\n \n\n \n \n \n tinytable_awbabfwmguq9gw7cr5m7\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen the sum of the width vector exceeds 1, it is automatically normalized to full-width. This is convenient when we only want to specify column width in relative terms:\n\ntt(x, width = c(3, 2, 1, 1, 1))\n\n \n\n \n \n \n tinytable_v5mbcr3wqz0o2oottx6g\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen specifying a table width, the text is automatically wrapped to appropriate size:\n\nlorem <- data.frame(\n Lorem = \"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\",\n Ipsum = \" Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos.\"\n)\n\ntt(lorem, width = 3/4)\n\n \n\n \n \n \n tinytable_148xv9rc0kwp2qsg84ti\n \n \n \n \n \n\n \n \n \n \n \n \n Lorem\n Ipsum\n \n \n \n \n \n Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\n Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos.",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -834,7 +834,7 @@
"href": "vignettes/tinytable.html#footnotes",
"title": "Tiny Tables",
"section": "",
- "text": "The notes argument accepts single strings or named lists of strings:\n\nn <- \"Fusce id ipsum consequat ante pellentesque iaculis eu a ipsum. Mauris id ex in nulla consectetur aliquam. In nec tempus diam. Aliquam arcu nibh, dapibus id ex vestibulum, feugiat consequat erat. Morbi feugiat dapibus malesuada. Quisque vel ullamcorper felis. Aenean a sem at nisi tempor pretium sit amet quis lacus.\"\n\ntt(lorem, notes = n, width = 1)\n\n \n\n \n \n \n tinytable_ag5juszxo16jaho46vus\n \n \n \n \n \n\n \n \n A full-width table with wrapped text in cells and a footnote.\n \n \n \n Lorem\n Ipsum\n \n \n Fusce id ipsum consequat ante pellentesque iaculis eu a ipsum. Mauris id ex in nulla consectetur aliquam. In nec tempus diam. Aliquam arcu nibh, dapibus id ex vestibulum, feugiat consequat erat. Morbi feugiat dapibus malesuada. Quisque vel ullamcorper felis. Aenean a sem at nisi tempor pretium sit amet quis lacus.\n \n \n Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\n Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos.\n \n \n \n \n\n \n\n \n\n\n\n\nWhen notes is a named list, the names are used as identifiers and displayed as superscripts:\n\ntt(x, notes = list(a = \"Blah.\", b = \"Blah blah.\"))\n\n \n\n \n \n \n tinytable_bm4d993g5ff1i1qwz0dr\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 a Blah.\nb Blah blah.\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also add markers in individual cells by providing coordinates:\n\ntt(x, notes = list(\n a = list(i = 0:1, j = 1, text = \"Blah.\"),\n b = \"Blah blah.\"\n )\n)\n\n \n\n \n \n \n tinytable_tn7rytyhbji68iixwjzb\n \n \n \n \n \n\n \n \n \n \n \n \n mpga\n cyl\n disp\n hp\n drat\n \n \n a Blah.\nb Blah blah.\n \n \n 21 a\n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
+ "text": "The notes argument accepts single strings or named lists of strings:\n\nn <- \"Fusce id ipsum consequat ante pellentesque iaculis eu a ipsum. Mauris id ex in nulla consectetur aliquam. In nec tempus diam. Aliquam arcu nibh, dapibus id ex vestibulum, feugiat consequat erat. Morbi feugiat dapibus malesuada. Quisque vel ullamcorper felis. Aenean a sem at nisi tempor pretium sit amet quis lacus.\"\n\ntt(lorem, notes = n, width = 1)\n\n \n\n \n \n \n tinytable_podlc9wwdhgmg5mgk3ke\n \n \n \n \n \n\n \n \n A full-width table with wrapped text in cells and a footnote.\n \n \n \n Lorem\n Ipsum\n \n \n Fusce id ipsum consequat ante pellentesque iaculis eu a ipsum. Mauris id ex in nulla consectetur aliquam. In nec tempus diam. Aliquam arcu nibh, dapibus id ex vestibulum, feugiat consequat erat. Morbi feugiat dapibus malesuada. Quisque vel ullamcorper felis. Aenean a sem at nisi tempor pretium sit amet quis lacus.\n \n \n Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.\n Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos.\n \n \n \n \n\n \n\n \n\n\n\n\nWhen notes is a named list, the names are used as identifiers and displayed as superscripts:\n\ntt(x, notes = list(a = \"Blah.\", b = \"Blah blah.\"))\n\n \n\n \n \n \n tinytable_pfvtd2nr809gnacpixdk\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 a Blah.\nb Blah blah.\n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also add markers in individual cells by providing coordinates:\n\ntt(x, notes = list(\n a = list(i = 0:1, j = 1, text = \"Blah.\"),\n b = \"Blah blah.\"\n )\n)\n\n \n\n \n \n \n tinytable_h27mk848lc0mhz0r474k\n \n \n \n \n \n\n \n \n \n \n \n \n mpga\n cyl\n disp\n hp\n drat\n \n \n a Blah.\nb Blah blah.\n \n \n 21 a\n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -846,7 +846,7 @@
"href": "vignettes/tinytable.html#captions-and-cross-references",
"title": "Tiny Tables",
"section": "",
- "text": "In Quarto, one should always specify captions cross-references using chunk options, and should not use the caption argument. This is because Quarto automatically post-processes tables, and may introduce conflict with the captions inserted by tinytable. For example:\n@tbl-blah shows that...\n\n```{r}\n#| label: tbl-blah\n#| tbl-cap: \"Blah blah blah\"\nlibrary(tinytable)\ntt(mtcars[1:4, 1:4])\n```\nAnd here is the rendered version of the code chunk above:\nTable 1 shows that…\n\nlibrary(tinytable)\ntt(mtcars[1:4, 1:4])\n\n\n\nTable 1: Blah blah blah\n\n\n\n \n\n \n \n \n tinytable_5i8cbvifmqbv32w7pxv6\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n 21 \n 6\n 160\n 110\n \n \n 21 \n 6\n 160\n 110\n \n \n 22.8\n 4\n 108\n 93\n \n \n 21.4\n 6\n 258\n 110\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nOne exception to the injunction above is when rendering a Quarto document to LaTeX using theme_tt(\"multipage\")\". In that case, one must avoid using the Quarto chunk option, because these options trigger Quarto post-processing that will conflict with the longtblr environment used to split long tables across multiple pages.\nThe alternative is to use to refer to tables using standard LaTeX syntax: \\ref{tbl-ex-multipage}. Then, use the caption argument in tt() to specify both the label and the caption:\n\ntt(iris, caption = \"Example table.\\\\label{tbl-ex-multipage}\") |>\n theme_tt(\"multipage\")\n\nFor standalone tables in any format (i.e., outside Quarto), you can use the caption argument like so:\n\ntt(x, caption = \"Blah blah.\\\\label{tbl-blah}\")",
+ "text": "In Quarto, one should always specify captions cross-references using chunk options, and should not use the caption argument. This is because Quarto automatically post-processes tables, and may introduce conflict with the captions inserted by tinytable. For example:\n@tbl-blah shows that...\n\n```{r}\n#| label: tbl-blah\n#| tbl-cap: \"Blah blah blah\"\nlibrary(tinytable)\ntt(mtcars[1:4, 1:4])\n```\nAnd here is the rendered version of the code chunk above:\nTable 1 shows that…\n\nlibrary(tinytable)\ntt(mtcars[1:4, 1:4])\n\n\n\nTable 1: Blah blah blah\n\n\n\n \n\n \n \n \n tinytable_j87t51w8kyftqmhjf3uc\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n \n \n \n \n \n 21 \n 6\n 160\n 110\n \n \n 21 \n 6\n 160\n 110\n \n \n 22.8\n 4\n 108\n 93\n \n \n 21.4\n 6\n 258\n 110\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nOne exception to the injunction above is when rendering a Quarto document to LaTeX using theme_tt(\"multipage\")\". In that case, one must avoid using the Quarto chunk option, because these options trigger Quarto post-processing that will conflict with the longtblr environment used to split long tables across multiple pages.\nThe alternative is to use to refer to tables using standard LaTeX syntax: \\ref{tbl-ex-multipage}. Then, use the caption argument in tt() to specify both the label and the caption:\n\ntt(iris, caption = \"Example table.\\\\label{tbl-ex-multipage}\") |>\n theme_tt(\"multipage\")\n\nFor standalone tables in any format (i.e., outside Quarto), you can use the caption argument like so:\n\ntt(x, caption = \"Blah blah.\\\\label{tbl-blah}\")",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -858,7 +858,7 @@
"href": "vignettes/tinytable.html#math",
"title": "Tiny Tables",
"section": "",
- "text": "To insert LaTeX-style mathematical expressions in a tinytable, we enclose the expression in dollar signs: $...$. The expression will then rendered as a mathematical expression by MathJax (for HTML), LaTeX, or Pandoc. Do not forget to double escape any backslashes.\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 tinytable_ymd7wuk2d0ghfcuhaw4m\n \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}$",
+ "text": "To insert LaTeX-style mathematical expressions in a tinytable, we enclose the expression in dollar signs: $...$. The expression will then rendered as a mathematical expression by MathJax (for HTML), LaTeX, or Pandoc. Do not forget to double escape any backslashes.\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 tinytable_18z19kklcybuo59jczbk\n \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}$",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -870,7 +870,7 @@
"href": "vignettes/tinytable.html#line-breaks-and-text-wrapping",
"title": "Tiny Tables",
"section": "",
- "text": "Manual line breaks work sligthly different in LaTeX (PDF) or HTML. This table shows the two strategies. For HTML, we insert a <br> tag. For LaTeX, we wrap the string in curly braces {}, and then insert two (escaped) backslashes: \\\\\\\\\n\nd <- data.frame(\n \"{Sed ut \\\\\\\\ perspiciatis unde}\",\n \"dicta sunt<br> explicabo. Nemo\"\n) |> setNames(c(\"LaTeX line break\", \"HTML line break\"))\ntt(d, width = 1)\n\n \n\n \n \n \n tinytable_0mpevmurjydteylfrlg6\n \n \n \n \n \n\n \n \n \n \n \n \n LaTeX line break\n HTML line break\n \n \n \n \n \n {Sed ut \\\\ perspiciatis unde}\n dicta sunt explicabo. Nemo",
+ "text": "Manual line breaks work sligthly different in LaTeX (PDF) or HTML. This table shows the two strategies. For HTML, we insert a <br> tag. For LaTeX, we wrap the string in curly braces {}, and then insert two (escaped) backslashes: \\\\\\\\\n\nd <- data.frame(\n \"{Sed ut \\\\\\\\ perspiciatis unde}\",\n \"dicta sunt<br> explicabo. Nemo\"\n) |> setNames(c(\"LaTeX line break\", \"HTML line break\"))\ntt(d, width = 1)\n\n \n\n \n \n \n tinytable_tfay8lyisiqtkgl1k74b\n \n \n \n \n \n\n \n \n \n \n \n \n LaTeX line break\n HTML line break\n \n \n \n \n \n {Sed ut \\\\ perspiciatis unde}\n dicta sunt explicabo. Nemo",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -894,7 +894,7 @@
"href": "vignettes/tinytable.html#combination-and-exploration",
"title": "Tiny Tables",
"section": "",
- "text": "Tables can be explored, modified, and combined using many of the usual base R functions:\n\na <- tt(mtcars[1:2, 1:2])\na\n\n \n\n \n \n \n tinytable_pwc8s1ytmmau9vb15m29\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n \n \n \n \n \n 21\n 6\n \n \n 21\n 6\n \n \n \n \n\n \n\n \n\n\n\ndim(a)\n\n[1] 2 2\n\nncol(a)\n\n[1] 2\n\nnrow(a)\n\n[1] 2\n\ncolnames(a)\n\n[1] \"mpg\" \"cyl\"\n\n\nRename columns:\n\ncolnames(a) <- c(\"a\", \"b\")\na\n\n \n\n \n \n \n tinytable_3bic6igzgzd13h7z2ahu\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 21\n 6\n \n \n 21\n 6\n \n \n \n \n\n \n\n \n\n\n\n\nTables can be combined with the usual rbind() function:\n\na <- tt(mtcars[1:3, 1:2], caption = \"Combine two tiny tables.\")\nb <- tt(mtcars[4:5, 8:10]) \n\nrbind(a, b)\n\n \n\n \n \n \n tinytable_7lwu800gy2b5nlgg8noo\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n vs\n am\n gear\n \n \n \n \n 1 \n 0 \n 3 \n \n \n \n \n 0 \n 0 \n 3 \n \n \n \n \n\n \n\n \n\n\n\nrbind(a, b) |> format_tt(replace = \"\")\n\n \n\n \n \n \n tinytable_fa65dkoo7qy3p7hr9k8n\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21\n 6\n \n \n \n \n \n 21\n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n vs\n am\n gear\n \n \n \n \n 1\n 0\n 3\n \n \n \n \n 0\n 0\n 3\n \n \n \n \n\n \n\n \n\n\n\n\nThe rbind2() S4 method is slightly more flexible than rbind(), as it supports arguments headers and use.names.\nOmit y header:\n\nrbind2(a, b, headers = FALSE)\n\n \n\n \n \n \n tinytable_b82d2zj80wnrmaip5jwg\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n 1\n 0\n 3\n \n \n \n \n 0\n 0\n 3\n \n \n \n \n\n \n\n \n\n\n\n\nBind tables by position rather than column names:\n\nrbind2(a, b, use_names = FALSE)\n\n \n\n \n \n \n tinytable_g80lo2xt15nt0e52jorq\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n gear\n \n \n \n \n \n 21 \n 6 \n \n \n \n 21 \n 6 \n \n \n \n 22.8\n 4 \n \n \n \n vs \n am\n gear\n \n \n 1 \n 0 \n 3 \n \n \n 0 \n 0 \n 3",
+ "text": "Tables can be explored, modified, and combined using many of the usual base R functions:\n\na <- tt(mtcars[1:2, 1:2])\na\n\n \n\n \n \n \n tinytable_te288c4b64rjkg684rdi\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n cyl\n \n \n \n \n \n 21\n 6\n \n \n 21\n 6\n \n \n \n \n\n \n\n \n\n\n\ndim(a)\n\n[1] 2 2\n\nncol(a)\n\n[1] 2\n\nnrow(a)\n\n[1] 2\n\ncolnames(a)\n\n[1] \"mpg\" \"cyl\"\n\n\nRename columns:\n\ncolnames(a) <- c(\"a\", \"b\")\na\n\n \n\n \n \n \n tinytable_ix93j4e72ae7nljruxvq\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 21\n 6\n \n \n 21\n 6\n \n \n \n \n\n \n\n \n\n\n\n\nTables can be combined with the usual rbind() function:\n\na <- tt(mtcars[1:3, 1:2], caption = \"Combine two tiny tables.\")\nb <- tt(mtcars[4:5, 8:10]) \n\nrbind(a, b)\n\n \n\n \n \n \n tinytable_vgipcv65p41fj15u0pua\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n vs\n am\n gear\n \n \n \n \n 1 \n 0 \n 3 \n \n \n \n \n 0 \n 0 \n 3 \n \n \n \n \n\n \n\n \n\n\n\nrbind(a, b) |> format_tt(replace = \"\")\n\n \n\n \n \n \n tinytable_n58taewpe4fik0ns36bg\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21\n 6\n \n \n \n \n \n 21\n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n vs\n am\n gear\n \n \n \n \n 1\n 0\n 3\n \n \n \n \n 0\n 0\n 3\n \n \n \n \n\n \n\n \n\n\n\n\nThe rbind2() S4 method is slightly more flexible than rbind(), as it supports arguments headers and use.names.\nOmit y header:\n\nrbind2(a, b, headers = FALSE)\n\n \n\n \n \n \n tinytable_w2wj4fuvrd9qml2r6dqg\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n vs\n am\n gear\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 21 \n 6\n \n \n \n \n \n 22.8\n 4\n \n \n \n \n \n \n \n 1\n 0\n 3\n \n \n \n \n 0\n 0\n 3\n \n \n \n \n\n \n\n \n\n\n\n\nBind tables by position rather than column names:\n\nrbind2(a, b, use_names = FALSE)\n\n \n\n \n \n \n tinytable_0kpsmer3h30he89vcqba\n \n \n \n \n \n\n \n \n \n \n Combine two tiny tables.\n \n mpg\n cyl\n gear\n \n \n \n \n \n 21 \n 6 \n \n \n \n 21 \n 6 \n \n \n \n 22.8\n 4 \n \n \n \n vs \n am\n gear\n \n \n 1 \n 0 \n 3 \n \n \n 0 \n 0 \n 3",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -906,7 +906,7 @@
"href": "vignettes/style.html",
"title": "Style",
"section": "",
- "text": "The main styling function for the tinytable package is style_tt(). Via this function, you can access three main interfaces to customize tables:\n\nA general interface to frequently used style choices which works for both HTML and LaTeX (PDF): colors, font style and size, row and column spans, etc. This is accessed through several distinct arguments in the style_tt() function, such as italic, color, etc.\nA specialized interface which allows users to use the powerful tabularray package to customize LaTeX tables. This is accessed by passing tabularray settings as strings to the tabularray_inner and tabularray_outer arguments of style_tt().\nA specialized interface which allows users to use the powerful Bootstrap framework to customize HTML tables. This is accessed by passing CSS declarations and rules to the bootstrap_css and bootstrap_css_rule arguments of style_tt().\n\nThese functions can be used to customize rows, columns, or individual cells. They control many features, including:\n\nText color\nBackground color\nWidths\nHeights\nAlignment\nText Wrapping\nColumn and Row Spacing\nCell Merging\nMulti-row or column spans\nBorder Styling\nFont Styling: size, underline, italic, bold, strikethrough, etc.\nHeader Customization\n\nThe style_*() functions can modify individual cells, or entire columns and rows. The portion of the table that is styled is determined by the i (rows) and j (columns) arguments.\n\nlibrary(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\nx <- mtcars[1:4, 1:5]\n\n\n\nTo 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:\n\ntt(x) |>\n style_tt(\n i = 2,\n j = 3,\n background = \"black\",\n color = \"white\")\n\n \n\n \n \n \n tinytable_f0gt7kfbw9ynjqot65sy\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nThe i and j accept vectors of integers to modify several cells at once:\n\ntt(x) |>\n style_tt(\n i = 2:3,\n j = c(1, 3, 4),\n italic = TRUE,\n color = \"orange\")\n\n \n\n \n \n \n tinytable_fdid110picuma1v2h82n\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style all cells in a table by omitting both the i and j arguments:\n\ntt(x) |> style_tt(color = \"orange\")\n\n \n\n \n \n \n tinytable_6hmemgjth4t96vtk71no\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style entire rows by omitting the j argument:\n\ntt(x) |> style_tt(i = 1:2, color = \"orange\")\n\n \n\n \n \n \n tinytable_fe17wlfb4l8xr2kib00f\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style entire columns by omitting the i argument:\n\ntt(x) |> style_tt(j = c(2, 4), bold = TRUE)\n\n \n\n \n \n \n tinytable_fby236gsnra94h3hdw5j\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nThe j argument accepts integer vectors, character vectors, but also a string with a Perl-style regular expression, which makes it easier to select columns by name:\n\ntt(x) |> style_tt(j = c(\"mpg\", \"drat\"), color = \"orange\")\n\n \n\n \n \n \n tinytable_wk821wh29lepjr67jz0p\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x) |> style_tt(j = \"mpg|drat\", color = \"orange\")\n\n \n\n \n \n \n tinytable_8ishhbwsiump99is9g31\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nHere we use a “negative lookahead” to exclude certain columns:\n\ntt(x) |> style_tt(j = \"^(?!drat|mpg)\", color = \"orange\")\n\n \n\n \n \n \n tinytable_l96em2m3fo6jgm9ou04k\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nOf course, we can also call the style_tt() function several times to apply different styles to different parts of the table:\n\ntt(x) |> \n style_tt(i = 1, j = 1:2, color = \"orange\") |>\n style_tt(i = 1, j = 3:4, color = \"green\")\n\n \n\n \n \n \n tinytable_nju3b3hjrt3gmkv7imxu\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe color and background arguments in the style_tt() function are used for specifying the text color and the background color for cells of a table created by the tt() function. This argument plays a crucial role in enhancing the visual appeal and readability of the table, whether it’s rendered in LaTeX or HTML format. The way we specify colors differs slightly between the two formats:\nFor HTML Output:\n\nHex Codes: You can specify colors using hexadecimal codes, which consist of a # followed by 6 characters (e.g., #CC79A7). This allows for a wide range of colors.\nKeywords: There’s also the option to use color keywords for convenience. The supported keywords are basic color names like black, red, blue, etc.\n\nFor LaTeX Output:\n\nHexadecimal Codes: Similar to HTML, you can use hexadecimal codes. However, in LaTeX, you need to include these codes as strings (e.g., \"#CC79A7\").\nKeywords: LaTeX supports a different set of color keywords, which include standard colors like black, red, blue, as well as additional ones like cyan, darkgray, lightgray, etc.\nColor Blending: An advanced feature in LaTeX is color blending, which can be achieved using the xcolor package. You can blend colors by specifying ratios (e.g., white!80!blue or green!20!red).\nLuminance Levels: The ninecolors package in LaTeX offers colors with predefined luminance levels, allowing for more nuanced color choices (e.g., “azure4”, “magenta8”).\n\nNote that the keywords used in LaTeX and HTML are slightly different.\n\ntt(x) |> style_tt(i = 1:4, j = 1, color = \"#FF5733\")\n\n \n\n \n \n \n tinytable_rm58b2xzvlqoxtcfjxji\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nNote that when using Hex codes in a LaTeX table, we need extra declarations in the LaTeX preamble. See ?tt for details.\n\n\n\nTo align columns, we use a single character, or a string where each letter represents a column:\n\ndat <- data.frame(\n a = c(\"a\", \"aa\", \"aaa\"),\n b = c(\"b\", \"bb\", \"bbb\"),\n c = c(\"c\", \"cc\", \"ccc\"))\n\ntt(dat) |> style_tt(j = 1:3, align = \"c\")\n\n \n\n \n \n \n tinytable_xuq30p0or02419jj524x\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n a \n b \n c \n \n \n aa \n bb \n cc \n \n \n aaa\n bbb\n ccc\n \n \n \n \n\n \n\n \n\n\n\ntt(dat) |> style_tt(j = 1:3, align = \"lcr\")\n\n \n\n \n \n \n tinytable_of3vsi89nmcyetlcxecj\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n a \n b \n c \n \n \n aa \n bb \n cc \n \n \n aaa\n bbb\n ccc\n \n \n \n \n\n \n\n \n\n\n\n\nIn LaTeX documents (only), we can use decimal-alignment:\n\nz <- data.frame(pi = c(pi * 100, pi * 1000, pi * 10000, pi * 100000))\ntt(z) |>\n format_tt(j = 1, digits = 8, num_fmt = \"significant_cell\") |>\n style_tt(j = 1, align = \"d\")\n\n \n\n \n \n \n tinytable_0x5hv2nyjhtbfzwcd91g\n \n \n \n \n \n\n \n \n \n \n \n \n pi\n \n \n \n \n \n 314.15927\n \n \n 3141.5927\n \n \n 31415.927\n \n \n 314159.27\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe font size is specified in em units.\n\ntt(x) |> style_tt(j = \"mpg|hp|qsec\", fontsize = 1.5)\n\n \n\n \n \n \n tinytable_gbb99pe9git0mns4jokt\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nSometimes, it can be useful to make a cell stretch across multiple colums or rows, for example when we want to insert a label. To achieve this, we can use the colspan argument. Here, we make the 2nd cell of the 2nd row stretch across three columns and two rows:\n\ntt(x)|> style_tt(\n i = 2, j = 2,\n colspan = 3,\n rowspan = 2,\n align = \"c\",\n alignv = \"m\",\n color = \"white\",\n background = \"black\",\n bold = TRUE)\n\n \n\n \n \n \n tinytable_3okputrewwm3hh3b5i44\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nHere is the original table for comparison:\n\ntt(x)\n\n \n\n \n \n \n tinytable_4h50j6jw6p2pywlxsc5x\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nSpanning cells can be particularly useful when we want to suppress redundant labels:\n\ntab <- aggregate(mpg ~ cyl + am, FUN = mean, data = mtcars)\ntab <- tab[order(tab$cyl, tab$am),]\ntab\n\n cyl am mpg\n1 4 0 22.90000\n4 4 1 28.07500\n2 6 0 19.12500\n5 6 1 20.56667\n3 8 0 15.05000\n6 8 1 15.40000\n\ntt(tab, digits = 2) |>\n style_tt(i = c(1, 3, 5), j = 1, rowspan = 2, alignv = \"t\")\n\n \n\n \n \n \n tinytable_xwbeknm58kv2paojmfad\n \n \n \n \n \n\n \n \n \n \n \n \n cyl\n am\n mpg\n \n \n \n \n \n 4\n 0\n 23\n \n \n 4\n 1\n 28\n \n \n 6\n 0\n 19\n \n \n 6\n 1\n 21\n \n \n 8\n 0\n 15\n \n \n 8\n 1\n 15\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe header can be omitted from the table by deleting the column names in the x data frame:\n\nk <- x\ncolnames(k) <- NULL\ntt(k)\n\n \n\n \n \n \n tinytable_2j70q6noi5jdy8lz39b6\n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nThe first is row 0, and higher level headers (ex: column spanning labels) have negative indices like -1. They can be styled as expected:\n\ntt(x) |> style_tt(i = 0, color = \"white\", background = \"black\")\n\n \n\n \n \n \n tinytable_gs1iyrm2osym0xei6963\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen styling columns without specifying i, the headers are styled in accordance with the rest of the column:\n\ntt(x) |> style_tt(j = 2:3, color = \"white\", background = \"black\")\n\n \n\n \n \n \n tinytable_sz7t1tbcevlkr46m712j\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nWe 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:\n\nk <- mtcars[1:10, c(\"mpg\", \"am\", \"vs\")]\n\ntt(k) |> \n style_tt(\n i = which(k$am == k$vs),\n background = \"teal\",\n color = \"white\")\n\n \n\n \n \n \n tinytable_gl91yu2tydxbh75x6pax\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n am\n vs\n \n \n \n \n \n 21 \n 1\n 0\n \n \n 21 \n 1\n 0\n \n \n 22.8\n 1\n 1\n \n \n 21.4\n 0\n 1\n \n \n 18.7\n 0\n 0\n \n \n 18.1\n 0\n 1\n \n \n 14.3\n 0\n 0\n \n \n 24.4\n 0\n 1\n \n \n 22.8\n 0\n 1\n \n \n 19.2\n 0\n 1\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe color, background, and fontsize arguments are vectorized. This allows easy specification of different colors in a single call:\n\ntt(x) |>\n style_tt(\n i = 1:4,\n color = c(\"red\", \"blue\", \"green\", \"orange\"))\n\n \n\n \n \n \n tinytable_7aj23uxqwtjuf114ncrm\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen using a single value for a vectorized argument, it gets applied to all values:\n\ntt(x) |>\n style_tt(\n j = 2:3,\n color = c(\"orange\", \"green\"),\n background = \"black\")\n\n \n\n \n \n \n tinytable_u7u4wve7bjeakwxqzife\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also produce more complex heatmap-like tables to illustrate different font sizes in em units:\n\n# font sizes\nfs <- seq(.1, 2, length.out = 20)\n\n# headless table\nk <- data.frame(matrix(fs, ncol = 5))\ncolnames(k) <- NULL\n\n# colors\nbg <- hcl.colors(20, \"Inferno\")\nfg <- ifelse(as.matrix(k) < 1.7, tail(bg, 1), head(bg, 1))\n\n# table\ntt(k, width = .7, theme = \"void\") |>\n style_tt(j = 1:5, align = \"ccccc\") |>\n style_tt(\n i = 1:4,\n j = 1:5,\n color = fg,\n background = bg,\n fontsize = fs)\n\n \n\n \n \n \n tinytable_mklsu8o0zo76tyqf0wvm\n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 0.1\n 0.5\n 0.9\n 1.3\n 1.7\n \n \n 0.2\n 0.6\n 1.0\n 1.4\n 1.8\n \n \n 0.3\n 0.7\n 1.1\n 1.5\n 1.9\n \n \n 0.4\n 0.8\n 1.2\n 1.6\n 2.0\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe style_tt function allows us to customize the borders that surround eacell of a table, as well horizontal and vertical rules. To control these lines, we use the line, line_width, and line_color arguments. Here’s a brief overview of each of these arguments:\n\nline: This argument specifies where solid lines should be drawn. It is a string that can consist of the following characters:\n\n\"t\": Draw a line at the top of the cell, row, or column.\n\"b\": Draw a line at the bottom of the cell, row, or column.\n\"l\": Draw a line at the left side of the cell, row, or column.\n\"r\": Draw a line at the right side of the cell, row, or column.\nYou can combine these characters to draw lines on multiple sides, such as \"tbl\" to draw lines at the top, bottom, and left sides of a cell.\n\nline_width: This argument controls the width of the solid lines in em units (default: 0.1 em). You can adjust this value to make the lines thicker or thinner.\nline_color: Specifies the color of the solid lines. You can use color names, hexadecimal codes, or other color specifications to define the line color.\n\nHere is an example where we draw lines around every border (“t”, “b”, “l”, and “r”) of specified cells.\n\ntt(x, theme = \"void\") |>\n style_tt(\n i = 0:3,\n j = 1:3,\n line = \"tblr\",\n line_width = 0.4,\n line_color = \"orange\")\n\n \n\n \n \n \n tinytable_79fi11owuq7vci6g4ukp\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nAnd here is an example with horizontal rules:\n\ntt(x, theme = \"void\") |>\n style_tt(i = 0, line = \"t\", line_color = \"orange\", line_width = 0.4) |>\n style_tt(i = 0, line = \"b\", line_color = \"purple\", line_width = 0.2) |>\n style_tt(i = 4, line = \"b\", line_color = \"orange\", line_width = 0.4)\n\n \n\n \n \n \n tinytable_8njze7p625uhncuwtv50\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ndat <- data.frame(1:2, 3:4, 5:6, 7:8)\ncolnames(dat) <- NULL\n\ntt(dat, theme = \"void\") |> \n style_tt(\n line = \"tblr\", line_color = \"white\", line_width = 0.5,\n background = \"blue\", color = \"white\")\n\n \n\n \n \n \n tinytable_wteljnshus2qywocge0c\n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 1\n 3\n 5\n 7\n \n \n 2\n 4\n 6\n 8\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThere is no argument in style_tt() to control the padding of cells. Thankfully, this is easy to control using CSS and tabularray options:\n\ntt(x) |> style_tt(\n i = 1:5,\n bootstrap_css = \"padding-right: .2em; padding-top: 2em;\",\n tabularray_inner = \"rowsep={2em}, colsep = {.2em}\"\n)\n\n \n\n \n \n \n tinytable_wfra9avyxg1flyklah0i\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nStyling for Markdown and Word tables is more limited than for the other formats. In particular:\n\nThe only supported arguments are: bold, italic, and strikeout.\nHeaders inserted by group_tt() cannot be styled using the style_tt() function.\n\nThese limitations are due to the fact that there is no markdown syntax for the other options (ex: colors and background), and that we create Word documents by converting a markdown table to .docx via the Pandoc software.\nOne workaround is to style the group headers directly in their definition by using markdown syntax:\n\nmtcars[1:4, 1:4] |>\n tt() |>\n group_tt(i = list(\"*Hello*\" = 1, \"__World__\" = 3)) |>\n print(\"markdown\")\n\n+------+-----+------+-----+\n| mpg | cyl | disp | hp |\n+======+=====+======+=====+\n| *Hello* |\n+------+-----+------+-----+\n| 21 | 6 | 160 | 110 |\n+------+-----+------+-----+\n| 21 | 6 | 160 | 110 |\n+------+-----+------+-----+\n| __World__ |\n+------+-----+------+-----+\n| 22.8 | 4 | 108 | 93 |\n+------+-----+------+-----+\n| 21.4 | 6 | 258 | 110 |\n+------+-----+------+-----+",
+ "text": "The main styling function for the tinytable package is style_tt(). Via this function, you can access three main interfaces to customize tables:\n\nA general interface to frequently used style choices which works for both HTML and LaTeX (PDF): colors, font style and size, row and column spans, etc. This is accessed through several distinct arguments in the style_tt() function, such as italic, color, etc.\nA specialized interface which allows users to use the powerful tabularray package to customize LaTeX tables. This is accessed by passing tabularray settings as strings to the tabularray_inner and tabularray_outer arguments of style_tt().\nA specialized interface which allows users to use the powerful Bootstrap framework to customize HTML tables. This is accessed by passing CSS declarations and rules to the bootstrap_css and bootstrap_css_rule arguments of style_tt().\n\nThese functions can be used to customize rows, columns, or individual cells. They control many features, including:\n\nText color\nBackground color\nWidths\nHeights\nAlignment\nText Wrapping\nColumn and Row Spacing\nCell Merging\nMulti-row or column spans\nBorder Styling\nFont Styling: size, underline, italic, bold, strikethrough, etc.\nHeader Customization\n\nThe style_*() functions can modify individual cells, or entire columns and rows. The portion of the table that is styled is determined by the i (rows) and j (columns) arguments.\n\nlibrary(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\nx <- mtcars[1:4, 1:5]\n\n\n\nTo 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:\n\ntt(x) |>\n style_tt(\n i = 2,\n j = 3,\n background = \"black\",\n color = \"white\")\n\n \n\n \n \n \n tinytable_bbj7d3erphqdor8z763q\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nThe i and j accept vectors of integers to modify several cells at once:\n\ntt(x) |>\n style_tt(\n i = 2:3,\n j = c(1, 3, 4),\n italic = TRUE,\n color = \"orange\")\n\n \n\n \n \n \n tinytable_g1lwccaqw035q9zxbeor\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style all cells in a table by omitting both the i and j arguments:\n\ntt(x) |> style_tt(color = \"orange\")\n\n \n\n \n \n \n tinytable_truth4lgirloffpkq9kp\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style entire rows by omitting the j argument:\n\ntt(x) |> style_tt(i = 1:2, color = \"orange\")\n\n \n\n \n \n \n tinytable_a0p00ap6dytpzjm58e21\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style entire columns by omitting the i argument:\n\ntt(x) |> style_tt(j = c(2, 4), bold = TRUE)\n\n \n\n \n \n \n tinytable_iw7l400koamxwrql21o8\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nThe j argument accepts integer vectors, character vectors, but also a string with a Perl-style regular expression, which makes it easier to select columns by name:\n\ntt(x) |> style_tt(j = c(\"mpg\", \"drat\"), color = \"orange\")\n\n \n\n \n \n \n tinytable_6xmh8efiqfz63ocqzzow\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x) |> style_tt(j = \"mpg|drat\", color = \"orange\")\n\n \n\n \n \n \n tinytable_magyf5w20joi5vaap5ka\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nHere we use a “negative lookahead” to exclude certain columns:\n\ntt(x) |> style_tt(j = \"^(?!drat|mpg)\", color = \"orange\")\n\n \n\n \n \n \n tinytable_zs6mwlkwmjrxs5yd4jpc\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nOf course, we can also call the style_tt() function several times to apply different styles to different parts of the table:\n\ntt(x) |> \n style_tt(i = 1, j = 1:2, color = \"orange\") |>\n style_tt(i = 1, j = 3:4, color = \"green\")\n\n \n\n \n \n \n tinytable_jckpbjjz4o1vdnp6gpgn\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe color and background arguments in the style_tt() function are used for specifying the text color and the background color for cells of a table created by the tt() function. This argument plays a crucial role in enhancing the visual appeal and readability of the table, whether it’s rendered in LaTeX or HTML format. The way we specify colors differs slightly between the two formats:\nFor HTML Output:\n\nHex Codes: You can specify colors using hexadecimal codes, which consist of a # followed by 6 characters (e.g., #CC79A7). This allows for a wide range of colors.\nKeywords: There’s also the option to use color keywords for convenience. The supported keywords are basic color names like black, red, blue, etc.\n\nFor LaTeX Output:\n\nHexadecimal Codes: Similar to HTML, you can use hexadecimal codes. However, in LaTeX, you need to include these codes as strings (e.g., \"#CC79A7\").\nKeywords: LaTeX supports a different set of color keywords, which include standard colors like black, red, blue, as well as additional ones like cyan, darkgray, lightgray, etc.\nColor Blending: An advanced feature in LaTeX is color blending, which can be achieved using the xcolor package. You can blend colors by specifying ratios (e.g., white!80!blue or green!20!red).\nLuminance Levels: The ninecolors package in LaTeX offers colors with predefined luminance levels, allowing for more nuanced color choices (e.g., “azure4”, “magenta8”).\n\nNote that the keywords used in LaTeX and HTML are slightly different.\n\ntt(x) |> style_tt(i = 1:4, j = 1, color = \"#FF5733\")\n\n \n\n \n \n \n tinytable_ptur4nh0cmxmzfwf9256\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nNote that when using Hex codes in a LaTeX table, we need extra declarations in the LaTeX preamble. See ?tt for details.\n\n\n\nTo align columns, we use a single character, or a string where each letter represents a column:\n\ndat <- data.frame(\n a = c(\"a\", \"aa\", \"aaa\"),\n b = c(\"b\", \"bb\", \"bbb\"),\n c = c(\"c\", \"cc\", \"ccc\"))\n\ntt(dat) |> style_tt(j = 1:3, align = \"c\")\n\n \n\n \n \n \n tinytable_o3qts1pfa4q6sxkjnudq\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n a \n b \n c \n \n \n aa \n bb \n cc \n \n \n aaa\n bbb\n ccc\n \n \n \n \n\n \n\n \n\n\n\ntt(dat) |> style_tt(j = 1:3, align = \"lcr\")\n\n \n\n \n \n \n tinytable_0iorrcp41rud0du6ch3u\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n a \n b \n c \n \n \n aa \n bb \n cc \n \n \n aaa\n bbb\n ccc\n \n \n \n \n\n \n\n \n\n\n\n\nIn LaTeX documents (only), we can use decimal-alignment:\n\nz <- data.frame(pi = c(pi * 100, pi * 1000, pi * 10000, pi * 100000))\ntt(z) |>\n format_tt(j = 1, digits = 8, num_fmt = \"significant_cell\") |>\n style_tt(j = 1, align = \"d\")\n\n \n\n \n \n \n tinytable_xd9s3y10jkwe16n52tvm\n \n \n \n \n \n\n \n \n \n \n \n \n pi\n \n \n \n \n \n 314.15927\n \n \n 3141.5927\n \n \n 31415.927\n \n \n 314159.27\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe font size is specified in em units.\n\ntt(x) |> style_tt(j = \"mpg|hp|qsec\", fontsize = 1.5)\n\n \n\n \n \n \n tinytable_jkp8hpce6e5oi18kkp27\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nSometimes, it can be useful to make a cell stretch across multiple colums or rows, for example when we want to insert a label. To achieve this, we can use the colspan argument. Here, we make the 2nd cell of the 2nd row stretch across three columns and two rows:\n\ntt(x)|> style_tt(\n i = 2, j = 2,\n colspan = 3,\n rowspan = 2,\n align = \"c\",\n alignv = \"m\",\n color = \"white\",\n background = \"black\",\n bold = TRUE)\n\n \n\n \n \n \n tinytable_q1ynhw4ny7eemjgi5tc0\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nHere is the original table for comparison:\n\ntt(x)\n\n \n\n \n \n \n tinytable_cu1ki8rgiu8b3yoid87i\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nSpanning cells can be particularly useful when we want to suppress redundant labels:\n\ntab <- aggregate(mpg ~ cyl + am, FUN = mean, data = mtcars)\ntab <- tab[order(tab$cyl, tab$am),]\ntab\n\n cyl am mpg\n1 4 0 22.90000\n4 4 1 28.07500\n2 6 0 19.12500\n5 6 1 20.56667\n3 8 0 15.05000\n6 8 1 15.40000\n\ntt(tab, digits = 2) |>\n style_tt(i = c(1, 3, 5), j = 1, rowspan = 2, alignv = \"t\")\n\n \n\n \n \n \n tinytable_o685k9iqk1h7hkzn7q1u\n \n \n \n \n \n\n \n \n \n \n \n \n cyl\n am\n mpg\n \n \n \n \n \n 4\n 0\n 23\n \n \n 4\n 1\n 28\n \n \n 6\n 0\n 19\n \n \n 6\n 1\n 21\n \n \n 8\n 0\n 15\n \n \n 8\n 1\n 15\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe header can be omitted from the table by deleting the column names in the x data frame:\n\nk <- x\ncolnames(k) <- NULL\ntt(k)\n\n \n\n \n \n \n tinytable_9yatmf1zgs2it3n7v9p2\n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nThe first is row 0, and higher level headers (ex: column spanning labels) have negative indices like -1. They can be styled as expected:\n\ntt(x) |> style_tt(i = 0, color = \"white\", background = \"black\")\n\n \n\n \n \n \n tinytable_jt7iidlxiynacvkadtin\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen styling columns without specifying i, the headers are styled in accordance with the rest of the column:\n\ntt(x) |> style_tt(j = 2:3, color = \"white\", background = \"black\")\n\n \n\n \n \n \n tinytable_nq49s2pzl9m847bz3zev\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nWe 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:\n\nk <- mtcars[1:10, c(\"mpg\", \"am\", \"vs\")]\n\ntt(k) |> \n style_tt(\n i = which(k$am == k$vs),\n background = \"teal\",\n color = \"white\")\n\n \n\n \n \n \n tinytable_7952am7elm7lagnmjzvg\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n am\n vs\n \n \n \n \n \n 21 \n 1\n 0\n \n \n 21 \n 1\n 0\n \n \n 22.8\n 1\n 1\n \n \n 21.4\n 0\n 1\n \n \n 18.7\n 0\n 0\n \n \n 18.1\n 0\n 1\n \n \n 14.3\n 0\n 0\n \n \n 24.4\n 0\n 1\n \n \n 22.8\n 0\n 1\n \n \n 19.2\n 0\n 1\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe color, background, and fontsize arguments are vectorized. This allows easy specification of different colors in a single call:\n\ntt(x) |>\n style_tt(\n i = 1:4,\n color = c(\"red\", \"blue\", \"green\", \"orange\"))\n\n \n\n \n \n \n tinytable_qs3kkbjyiudb02u2obr7\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen using a single value for a vectorized argument, it gets applied to all values:\n\ntt(x) |>\n style_tt(\n j = 2:3,\n color = c(\"orange\", \"green\"),\n background = \"black\")\n\n \n\n \n \n \n tinytable_onnmzkhtw2ebesp178p5\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also produce more complex heatmap-like tables to illustrate different font sizes in em units:\n\n# font sizes\nfs <- seq(.1, 2, length.out = 20)\n\n# headless table\nk <- data.frame(matrix(fs, ncol = 5))\ncolnames(k) <- NULL\n\n# colors\nbg <- hcl.colors(20, \"Inferno\")\nfg <- ifelse(as.matrix(k) < 1.7, tail(bg, 1), head(bg, 1))\n\n# table\ntt(k, width = .7, theme = \"void\") |>\n style_tt(j = 1:5, align = \"ccccc\") |>\n style_tt(\n i = 1:4,\n j = 1:5,\n color = fg,\n background = bg,\n fontsize = fs)\n\n \n\n \n \n \n tinytable_yvc315eesyr1mmq46l83\n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 0.1\n 0.5\n 0.9\n 1.3\n 1.7\n \n \n 0.2\n 0.6\n 1.0\n 1.4\n 1.8\n \n \n 0.3\n 0.7\n 1.1\n 1.5\n 1.9\n \n \n 0.4\n 0.8\n 1.2\n 1.6\n 2.0\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThe style_tt function allows us to customize the borders that surround eacell of a table, as well horizontal and vertical rules. To control these lines, we use the line, line_width, and line_color arguments. Here’s a brief overview of each of these arguments:\n\nline: This argument specifies where solid lines should be drawn. It is a string that can consist of the following characters:\n\n\"t\": Draw a line at the top of the cell, row, or column.\n\"b\": Draw a line at the bottom of the cell, row, or column.\n\"l\": Draw a line at the left side of the cell, row, or column.\n\"r\": Draw a line at the right side of the cell, row, or column.\nYou can combine these characters to draw lines on multiple sides, such as \"tbl\" to draw lines at the top, bottom, and left sides of a cell.\n\nline_width: This argument controls the width of the solid lines in em units (default: 0.1 em). You can adjust this value to make the lines thicker or thinner.\nline_color: Specifies the color of the solid lines. You can use color names, hexadecimal codes, or other color specifications to define the line color.\n\nHere is an example where we draw lines around every border (“t”, “b”, “l”, and “r”) of specified cells.\n\ntt(x, theme = \"void\") |>\n style_tt(\n i = 0:3,\n j = 1:3,\n line = \"tblr\",\n line_width = 0.4,\n line_color = \"orange\")\n\n \n\n \n \n \n tinytable_mqn2c82h1gveayic5jwc\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nAnd here is an example with horizontal rules:\n\ntt(x, theme = \"void\") |>\n style_tt(i = 0, line = \"t\", line_color = \"orange\", line_width = 0.4) |>\n style_tt(i = 0, line = \"b\", line_color = \"purple\", line_width = 0.2) |>\n style_tt(i = 4, line = \"b\", line_color = \"orange\", line_width = 0.4)\n\n \n\n \n \n \n tinytable_1eailt87vh0ce7814yei\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ndat <- data.frame(1:2, 3:4, 5:6, 7:8)\ncolnames(dat) <- NULL\n\ntt(dat, theme = \"void\") |> \n style_tt(\n line = \"tblr\", line_color = \"white\", line_width = 0.5,\n background = \"blue\", color = \"white\")\n\n \n\n \n \n \n tinytable_f38goy17tj2rucuib2tq\n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 1\n 3\n 5\n 7\n \n \n 2\n 4\n 6\n 8\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nThere is no argument in style_tt() to control the padding of cells. Thankfully, this is easy to control using CSS and tabularray options:\n\ntt(x) |> style_tt(\n i = 1:5,\n bootstrap_css = \"padding-right: .2em; padding-top: 2em;\",\n tabularray_inner = \"rowsep={2em}, colsep = {.2em}\"\n)\n\n \n\n \n \n \n tinytable_k9d1irb7u4vl61k01hry\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\n\n\nStyling for Markdown and Word tables is more limited than for the other formats. In particular:\n\nThe only supported arguments are: bold, italic, and strikeout.\nHeaders inserted by group_tt() cannot be styled using the style_tt() function.\n\nThese limitations are due to the fact that there is no markdown syntax for the other options (ex: colors and background), and that we create Word documents by converting a markdown table to .docx via the Pandoc software.\nOne workaround is to style the group headers directly in their definition by using markdown syntax:\n\nmtcars[1:4, 1:4] |>\n tt() |>\n group_tt(i = list(\"*Hello*\" = 1, \"__World__\" = 3)) |>\n print(\"markdown\")\n\n+------+-----+------+-----+\n| mpg | cyl | disp | hp |\n+======+=====+======+=====+\n| *Hello* |\n+------+-----+------+-----+\n| 21 | 6 | 160 | 110 |\n+------+-----+------+-----+\n| 21 | 6 | 160 | 110 |\n+------+-----+------+-----+\n| __World__ |\n+------+-----+------+-----+\n| 22.8 | 4 | 108 | 93 |\n+------+-----+------+-----+\n| 21.4 | 6 | 258 | 110 |\n+------+-----+------+-----+",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -918,7 +918,7 @@
"href": "vignettes/style.html#cells-rows-columns",
"title": "Style",
"section": "",
- "text": "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:\n\ntt(x) |>\n style_tt(\n i = 2,\n j = 3,\n background = \"black\",\n color = \"white\")\n\n \n\n \n \n \n tinytable_f0gt7kfbw9ynjqot65sy\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nThe i and j accept vectors of integers to modify several cells at once:\n\ntt(x) |>\n style_tt(\n i = 2:3,\n j = c(1, 3, 4),\n italic = TRUE,\n color = \"orange\")\n\n \n\n \n \n \n tinytable_fdid110picuma1v2h82n\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style all cells in a table by omitting both the i and j arguments:\n\ntt(x) |> style_tt(color = \"orange\")\n\n \n\n \n \n \n tinytable_6hmemgjth4t96vtk71no\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style entire rows by omitting the j argument:\n\ntt(x) |> style_tt(i = 1:2, color = \"orange\")\n\n \n\n \n \n \n tinytable_fe17wlfb4l8xr2kib00f\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style entire columns by omitting the i argument:\n\ntt(x) |> style_tt(j = c(2, 4), bold = TRUE)\n\n \n\n \n \n \n tinytable_fby236gsnra94h3hdw5j\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nThe j argument accepts integer vectors, character vectors, but also a string with a Perl-style regular expression, which makes it easier to select columns by name:\n\ntt(x) |> style_tt(j = c(\"mpg\", \"drat\"), color = \"orange\")\n\n \n\n \n \n \n tinytable_wk821wh29lepjr67jz0p\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x) |> style_tt(j = \"mpg|drat\", color = \"orange\")\n\n \n\n \n \n \n tinytable_8ishhbwsiump99is9g31\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nHere we use a “negative lookahead” to exclude certain columns:\n\ntt(x) |> style_tt(j = \"^(?!drat|mpg)\", color = \"orange\")\n\n \n\n \n \n \n tinytable_l96em2m3fo6jgm9ou04k\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nOf course, we can also call the style_tt() function several times to apply different styles to different parts of the table:\n\ntt(x) |> \n style_tt(i = 1, j = 1:2, color = \"orange\") |>\n style_tt(i = 1, j = 3:4, color = \"green\")\n\n \n\n \n \n \n tinytable_nju3b3hjrt3gmkv7imxu\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
+ "text": "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:\n\ntt(x) |>\n style_tt(\n i = 2,\n j = 3,\n background = \"black\",\n color = \"white\")\n\n \n\n \n \n \n tinytable_bbj7d3erphqdor8z763q\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nThe i and j accept vectors of integers to modify several cells at once:\n\ntt(x) |>\n style_tt(\n i = 2:3,\n j = c(1, 3, 4),\n italic = TRUE,\n color = \"orange\")\n\n \n\n \n \n \n tinytable_g1lwccaqw035q9zxbeor\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style all cells in a table by omitting both the i and j arguments:\n\ntt(x) |> style_tt(color = \"orange\")\n\n \n\n \n \n \n tinytable_truth4lgirloffpkq9kp\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style entire rows by omitting the j argument:\n\ntt(x) |> style_tt(i = 1:2, color = \"orange\")\n\n \n\n \n \n \n tinytable_a0p00ap6dytpzjm58e21\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can style entire columns by omitting the i argument:\n\ntt(x) |> style_tt(j = c(2, 4), bold = TRUE)\n\n \n\n \n \n \n tinytable_iw7l400koamxwrql21o8\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nThe j argument accepts integer vectors, character vectors, but also a string with a Perl-style regular expression, which makes it easier to select columns by name:\n\ntt(x) |> style_tt(j = c(\"mpg\", \"drat\"), color = \"orange\")\n\n \n\n \n \n \n tinytable_6xmh8efiqfz63ocqzzow\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\ntt(x) |> style_tt(j = \"mpg|drat\", color = \"orange\")\n\n \n\n \n \n \n tinytable_magyf5w20joi5vaap5ka\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nHere we use a “negative lookahead” to exclude certain columns:\n\ntt(x) |> style_tt(j = \"^(?!drat|mpg)\", color = \"orange\")\n\n \n\n \n \n \n tinytable_zs6mwlkwmjrxs5yd4jpc\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nOf course, we can also call the style_tt() function several times to apply different styles to different parts of the table:\n\ntt(x) |> \n style_tt(i = 1, j = 1:2, color = \"orange\") |>\n style_tt(i = 1, j = 3:4, color = \"green\")\n\n \n\n \n \n \n tinytable_jckpbjjz4o1vdnp6gpgn\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -930,7 +930,7 @@
"href": "vignettes/style.html#colors",
"title": "Style",
"section": "",
- "text": "The color and background arguments in the style_tt() function are used for specifying the text color and the background color for cells of a table created by the tt() function. This argument plays a crucial role in enhancing the visual appeal and readability of the table, whether it’s rendered in LaTeX or HTML format. The way we specify colors differs slightly between the two formats:\nFor HTML Output:\n\nHex Codes: You can specify colors using hexadecimal codes, which consist of a # followed by 6 characters (e.g., #CC79A7). This allows for a wide range of colors.\nKeywords: There’s also the option to use color keywords for convenience. The supported keywords are basic color names like black, red, blue, etc.\n\nFor LaTeX Output:\n\nHexadecimal Codes: Similar to HTML, you can use hexadecimal codes. However, in LaTeX, you need to include these codes as strings (e.g., \"#CC79A7\").\nKeywords: LaTeX supports a different set of color keywords, which include standard colors like black, red, blue, as well as additional ones like cyan, darkgray, lightgray, etc.\nColor Blending: An advanced feature in LaTeX is color blending, which can be achieved using the xcolor package. You can blend colors by specifying ratios (e.g., white!80!blue or green!20!red).\nLuminance Levels: The ninecolors package in LaTeX offers colors with predefined luminance levels, allowing for more nuanced color choices (e.g., “azure4”, “magenta8”).\n\nNote that the keywords used in LaTeX and HTML are slightly different.\n\ntt(x) |> style_tt(i = 1:4, j = 1, color = \"#FF5733\")\n\n \n\n \n \n \n tinytable_rm58b2xzvlqoxtcfjxji\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nNote that when using Hex codes in a LaTeX table, we need extra declarations in the LaTeX preamble. See ?tt for details.",
+ "text": "The color and background arguments in the style_tt() function are used for specifying the text color and the background color for cells of a table created by the tt() function. This argument plays a crucial role in enhancing the visual appeal and readability of the table, whether it’s rendered in LaTeX or HTML format. The way we specify colors differs slightly between the two formats:\nFor HTML Output:\n\nHex Codes: You can specify colors using hexadecimal codes, which consist of a # followed by 6 characters (e.g., #CC79A7). This allows for a wide range of colors.\nKeywords: There’s also the option to use color keywords for convenience. The supported keywords are basic color names like black, red, blue, etc.\n\nFor LaTeX Output:\n\nHexadecimal Codes: Similar to HTML, you can use hexadecimal codes. However, in LaTeX, you need to include these codes as strings (e.g., \"#CC79A7\").\nKeywords: LaTeX supports a different set of color keywords, which include standard colors like black, red, blue, as well as additional ones like cyan, darkgray, lightgray, etc.\nColor Blending: An advanced feature in LaTeX is color blending, which can be achieved using the xcolor package. You can blend colors by specifying ratios (e.g., white!80!blue or green!20!red).\nLuminance Levels: The ninecolors package in LaTeX offers colors with predefined luminance levels, allowing for more nuanced color choices (e.g., “azure4”, “magenta8”).\n\nNote that the keywords used in LaTeX and HTML are slightly different.\n\ntt(x) |> style_tt(i = 1:4, j = 1, color = \"#FF5733\")\n\n \n\n \n \n \n tinytable_ptur4nh0cmxmzfwf9256\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nNote that when using Hex codes in a LaTeX table, we need extra declarations in the LaTeX preamble. See ?tt for details.",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -942,7 +942,7 @@
"href": "vignettes/style.html#alignment",
"title": "Style",
"section": "",
- "text": "To align columns, we use a single character, or a string where each letter represents a column:\n\ndat <- data.frame(\n a = c(\"a\", \"aa\", \"aaa\"),\n b = c(\"b\", \"bb\", \"bbb\"),\n c = c(\"c\", \"cc\", \"ccc\"))\n\ntt(dat) |> style_tt(j = 1:3, align = \"c\")\n\n \n\n \n \n \n tinytable_xuq30p0or02419jj524x\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n a \n b \n c \n \n \n aa \n bb \n cc \n \n \n aaa\n bbb\n ccc\n \n \n \n \n\n \n\n \n\n\n\ntt(dat) |> style_tt(j = 1:3, align = \"lcr\")\n\n \n\n \n \n \n tinytable_of3vsi89nmcyetlcxecj\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n a \n b \n c \n \n \n aa \n bb \n cc \n \n \n aaa\n bbb\n ccc\n \n \n \n \n\n \n\n \n\n\n\n\nIn LaTeX documents (only), we can use decimal-alignment:\n\nz <- data.frame(pi = c(pi * 100, pi * 1000, pi * 10000, pi * 100000))\ntt(z) |>\n format_tt(j = 1, digits = 8, num_fmt = \"significant_cell\") |>\n style_tt(j = 1, align = \"d\")\n\n \n\n \n \n \n tinytable_0x5hv2nyjhtbfzwcd91g\n \n \n \n \n \n\n \n \n \n \n \n \n pi\n \n \n \n \n \n 314.15927\n \n \n 3141.5927\n \n \n 31415.927\n \n \n 314159.27",
+ "text": "To align columns, we use a single character, or a string where each letter represents a column:\n\ndat <- data.frame(\n a = c(\"a\", \"aa\", \"aaa\"),\n b = c(\"b\", \"bb\", \"bbb\"),\n c = c(\"c\", \"cc\", \"ccc\"))\n\ntt(dat) |> style_tt(j = 1:3, align = \"c\")\n\n \n\n \n \n \n tinytable_o3qts1pfa4q6sxkjnudq\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n a \n b \n c \n \n \n aa \n bb \n cc \n \n \n aaa\n bbb\n ccc\n \n \n \n \n\n \n\n \n\n\n\ntt(dat) |> style_tt(j = 1:3, align = \"lcr\")\n\n \n\n \n \n \n tinytable_0iorrcp41rud0du6ch3u\n \n \n \n \n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n a \n b \n c \n \n \n aa \n bb \n cc \n \n \n aaa\n bbb\n ccc\n \n \n \n \n\n \n\n \n\n\n\n\nIn LaTeX documents (only), we can use decimal-alignment:\n\nz <- data.frame(pi = c(pi * 100, pi * 1000, pi * 10000, pi * 100000))\ntt(z) |>\n format_tt(j = 1, digits = 8, num_fmt = \"significant_cell\") |>\n style_tt(j = 1, align = \"d\")\n\n \n\n \n \n \n tinytable_xd9s3y10jkwe16n52tvm\n \n \n \n \n \n\n \n \n \n \n \n \n pi\n \n \n \n \n \n 314.15927\n \n \n 3141.5927\n \n \n 31415.927\n \n \n 314159.27",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -954,7 +954,7 @@
"href": "vignettes/style.html#font-size",
"title": "Style",
"section": "",
- "text": "The font size is specified in em units.\n\ntt(x) |> style_tt(j = \"mpg|hp|qsec\", fontsize = 1.5)\n\n \n\n \n \n \n tinytable_gbb99pe9git0mns4jokt\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
+ "text": "The font size is specified in em units.\n\ntt(x) |> style_tt(j = \"mpg|hp|qsec\", fontsize = 1.5)\n\n \n\n \n \n \n tinytable_jkp8hpce6e5oi18kkp27\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -966,7 +966,7 @@
"href": "vignettes/style.html#spanning-cells-merging-cells",
"title": "Style",
"section": "",
- "text": "Sometimes, it can be useful to make a cell stretch across multiple colums or rows, for example when we want to insert a label. To achieve this, we can use the colspan argument. Here, we make the 2nd cell of the 2nd row stretch across three columns and two rows:\n\ntt(x)|> style_tt(\n i = 2, j = 2,\n colspan = 3,\n rowspan = 2,\n align = \"c\",\n alignv = \"m\",\n color = \"white\",\n background = \"black\",\n bold = TRUE)\n\n \n\n \n \n \n tinytable_3okputrewwm3hh3b5i44\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nHere is the original table for comparison:\n\ntt(x)\n\n \n\n \n \n \n tinytable_4h50j6jw6p2pywlxsc5x\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nSpanning cells can be particularly useful when we want to suppress redundant labels:\n\ntab <- aggregate(mpg ~ cyl + am, FUN = mean, data = mtcars)\ntab <- tab[order(tab$cyl, tab$am),]\ntab\n\n cyl am mpg\n1 4 0 22.90000\n4 4 1 28.07500\n2 6 0 19.12500\n5 6 1 20.56667\n3 8 0 15.05000\n6 8 1 15.40000\n\ntt(tab, digits = 2) |>\n style_tt(i = c(1, 3, 5), j = 1, rowspan = 2, alignv = \"t\")\n\n \n\n \n \n \n tinytable_xwbeknm58kv2paojmfad\n \n \n \n \n \n\n \n \n \n \n \n \n cyl\n am\n mpg\n \n \n \n \n \n 4\n 0\n 23\n \n \n 4\n 1\n 28\n \n \n 6\n 0\n 19\n \n \n 6\n 1\n 21\n \n \n 8\n 0\n 15\n \n \n 8\n 1\n 15",
+ "text": "Sometimes, it can be useful to make a cell stretch across multiple colums or rows, for example when we want to insert a label. To achieve this, we can use the colspan argument. Here, we make the 2nd cell of the 2nd row stretch across three columns and two rows:\n\ntt(x)|> style_tt(\n i = 2, j = 2,\n colspan = 3,\n rowspan = 2,\n align = \"c\",\n alignv = \"m\",\n color = \"white\",\n background = \"black\",\n bold = TRUE)\n\n \n\n \n \n \n tinytable_q1ynhw4ny7eemjgi5tc0\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nHere is the original table for comparison:\n\ntt(x)\n\n \n\n \n \n \n tinytable_cu1ki8rgiu8b3yoid87i\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nSpanning cells can be particularly useful when we want to suppress redundant labels:\n\ntab <- aggregate(mpg ~ cyl + am, FUN = mean, data = mtcars)\ntab <- tab[order(tab$cyl, tab$am),]\ntab\n\n cyl am mpg\n1 4 0 22.90000\n4 4 1 28.07500\n2 6 0 19.12500\n5 6 1 20.56667\n3 8 0 15.05000\n6 8 1 15.40000\n\ntt(tab, digits = 2) |>\n style_tt(i = c(1, 3, 5), j = 1, rowspan = 2, alignv = \"t\")\n\n \n\n \n \n \n tinytable_o685k9iqk1h7hkzn7q1u\n \n \n \n \n \n\n \n \n \n \n \n \n cyl\n am\n mpg\n \n \n \n \n \n 4\n 0\n 23\n \n \n 4\n 1\n 28\n \n \n 6\n 0\n 19\n \n \n 6\n 1\n 21\n \n \n 8\n 0\n 15\n \n \n 8\n 1\n 15",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -978,7 +978,7 @@
"href": "vignettes/style.html#headers",
"title": "Style",
"section": "",
- "text": "The header can be omitted from the table by deleting the column names in the x data frame:\n\nk <- x\ncolnames(k) <- NULL\ntt(k)\n\n \n\n \n \n \n tinytable_2j70q6noi5jdy8lz39b6\n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nThe first is row 0, and higher level headers (ex: column spanning labels) have negative indices like -1. They can be styled as expected:\n\ntt(x) |> style_tt(i = 0, color = \"white\", background = \"black\")\n\n \n\n \n \n \n tinytable_gs1iyrm2osym0xei6963\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen styling columns without specifying i, the headers are styled in accordance with the rest of the column:\n\ntt(x) |> style_tt(j = 2:3, color = \"white\", background = \"black\")\n\n \n\n \n \n \n tinytable_sz7t1tbcevlkr46m712j\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
+ "text": "The header can be omitted from the table by deleting the column names in the x data frame:\n\nk <- x\ncolnames(k) <- NULL\ntt(k)\n\n \n\n \n \n \n tinytable_9yatmf1zgs2it3n7v9p2\n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nThe first is row 0, and higher level headers (ex: column spanning labels) have negative indices like -1. They can be styled as expected:\n\ntt(x) |> style_tt(i = 0, color = \"white\", background = \"black\")\n\n \n\n \n \n \n tinytable_jt7iidlxiynacvkadtin\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen styling columns without specifying i, the headers are styled in accordance with the rest of the column:\n\ntt(x) |> style_tt(j = 2:3, color = \"white\", background = \"black\")\n\n \n\n \n \n \n tinytable_nq49s2pzl9m847bz3zev\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -990,7 +990,7 @@
"href": "vignettes/style.html#conditional-styling",
"title": "Style",
"section": "",
- "text": "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:\n\nk <- mtcars[1:10, c(\"mpg\", \"am\", \"vs\")]\n\ntt(k) |> \n style_tt(\n i = which(k$am == k$vs),\n background = \"teal\",\n color = \"white\")\n\n \n\n \n \n \n tinytable_gl91yu2tydxbh75x6pax\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n am\n vs\n \n \n \n \n \n 21 \n 1\n 0\n \n \n 21 \n 1\n 0\n \n \n 22.8\n 1\n 1\n \n \n 21.4\n 0\n 1\n \n \n 18.7\n 0\n 0\n \n \n 18.1\n 0\n 1\n \n \n 14.3\n 0\n 0\n \n \n 24.4\n 0\n 1\n \n \n 22.8\n 0\n 1\n \n \n 19.2\n 0\n 1",
+ "text": "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:\n\nk <- mtcars[1:10, c(\"mpg\", \"am\", \"vs\")]\n\ntt(k) |> \n style_tt(\n i = which(k$am == k$vs),\n background = \"teal\",\n color = \"white\")\n\n \n\n \n \n \n tinytable_7952am7elm7lagnmjzvg\n \n \n \n \n \n\n \n \n \n \n \n \n mpg\n am\n vs\n \n \n \n \n \n 21 \n 1\n 0\n \n \n 21 \n 1\n 0\n \n \n 22.8\n 1\n 1\n \n \n 21.4\n 0\n 1\n \n \n 18.7\n 0\n 0\n \n \n 18.1\n 0\n 1\n \n \n 14.3\n 0\n 0\n \n \n 24.4\n 0\n 1\n \n \n 22.8\n 0\n 1\n \n \n 19.2\n 0\n 1",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -1002,7 +1002,7 @@
"href": "vignettes/style.html#vectorized-styling-heatmaps",
"title": "Style",
"section": "",
- "text": "The color, background, and fontsize arguments are vectorized. This allows easy specification of different colors in a single call:\n\ntt(x) |>\n style_tt(\n i = 1:4,\n color = c(\"red\", \"blue\", \"green\", \"orange\"))\n\n \n\n \n \n \n tinytable_7aj23uxqwtjuf114ncrm\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen using a single value for a vectorized argument, it gets applied to all values:\n\ntt(x) |>\n style_tt(\n j = 2:3,\n color = c(\"orange\", \"green\"),\n background = \"black\")\n\n \n\n \n \n \n tinytable_u7u4wve7bjeakwxqzife\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also produce more complex heatmap-like tables to illustrate different font sizes in em units:\n\n# font sizes\nfs <- seq(.1, 2, length.out = 20)\n\n# headless table\nk <- data.frame(matrix(fs, ncol = 5))\ncolnames(k) <- NULL\n\n# colors\nbg <- hcl.colors(20, \"Inferno\")\nfg <- ifelse(as.matrix(k) < 1.7, tail(bg, 1), head(bg, 1))\n\n# table\ntt(k, width = .7, theme = \"void\") |>\n style_tt(j = 1:5, align = \"ccccc\") |>\n style_tt(\n i = 1:4,\n j = 1:5,\n color = fg,\n background = bg,\n fontsize = fs)\n\n \n\n \n \n \n tinytable_mklsu8o0zo76tyqf0wvm\n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 0.1\n 0.5\n 0.9\n 1.3\n 1.7\n \n \n 0.2\n 0.6\n 1.0\n 1.4\n 1.8\n \n \n 0.3\n 0.7\n 1.1\n 1.5\n 1.9\n \n \n 0.4\n 0.8\n 1.2\n 1.6\n 2.0",
+ "text": "The color, background, and fontsize arguments are vectorized. This allows easy specification of different colors in a single call:\n\ntt(x) |>\n style_tt(\n i = 1:4,\n color = c(\"red\", \"blue\", \"green\", \"orange\"))\n\n \n\n \n \n \n tinytable_qs3kkbjyiudb02u2obr7\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWhen using a single value for a vectorized argument, it gets applied to all values:\n\ntt(x) |>\n style_tt(\n j = 2:3,\n color = c(\"orange\", \"green\"),\n background = \"black\")\n\n \n\n \n \n \n tinytable_onnmzkhtw2ebesp178p5\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nWe can also produce more complex heatmap-like tables to illustrate different font sizes in em units:\n\n# font sizes\nfs <- seq(.1, 2, length.out = 20)\n\n# headless table\nk <- data.frame(matrix(fs, ncol = 5))\ncolnames(k) <- NULL\n\n# colors\nbg <- hcl.colors(20, \"Inferno\")\nfg <- ifelse(as.matrix(k) < 1.7, tail(bg, 1), head(bg, 1))\n\n# table\ntt(k, width = .7, theme = \"void\") |>\n style_tt(j = 1:5, align = \"ccccc\") |>\n style_tt(\n i = 1:4,\n j = 1:5,\n color = fg,\n background = bg,\n fontsize = fs)\n\n \n\n \n \n \n tinytable_yvc315eesyr1mmq46l83\n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 0.1\n 0.5\n 0.9\n 1.3\n 1.7\n \n \n 0.2\n 0.6\n 1.0\n 1.4\n 1.8\n \n \n 0.3\n 0.7\n 1.1\n 1.5\n 1.9\n \n \n 0.4\n 0.8\n 1.2\n 1.6\n 2.0",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -1014,7 +1014,7 @@
"href": "vignettes/style.html#lines-borders",
"title": "Style",
"section": "",
- "text": "The style_tt function allows us to customize the borders that surround eacell of a table, as well horizontal and vertical rules. To control these lines, we use the line, line_width, and line_color arguments. Here’s a brief overview of each of these arguments:\n\nline: This argument specifies where solid lines should be drawn. It is a string that can consist of the following characters:\n\n\"t\": Draw a line at the top of the cell, row, or column.\n\"b\": Draw a line at the bottom of the cell, row, or column.\n\"l\": Draw a line at the left side of the cell, row, or column.\n\"r\": Draw a line at the right side of the cell, row, or column.\nYou can combine these characters to draw lines on multiple sides, such as \"tbl\" to draw lines at the top, bottom, and left sides of a cell.\n\nline_width: This argument controls the width of the solid lines in em units (default: 0.1 em). You can adjust this value to make the lines thicker or thinner.\nline_color: Specifies the color of the solid lines. You can use color names, hexadecimal codes, or other color specifications to define the line color.\n\nHere is an example where we draw lines around every border (“t”, “b”, “l”, and “r”) of specified cells.\n\ntt(x, theme = \"void\") |>\n style_tt(\n i = 0:3,\n j = 1:3,\n line = \"tblr\",\n line_width = 0.4,\n line_color = \"orange\")\n\n \n\n \n \n \n tinytable_79fi11owuq7vci6g4ukp\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nAnd here is an example with horizontal rules:\n\ntt(x, theme = \"void\") |>\n style_tt(i = 0, line = \"t\", line_color = \"orange\", line_width = 0.4) |>\n style_tt(i = 0, line = \"b\", line_color = \"purple\", line_width = 0.2) |>\n style_tt(i = 4, line = \"b\", line_color = \"orange\", line_width = 0.4)\n\n \n\n \n \n \n tinytable_8njze7p625uhncuwtv50\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ndat <- data.frame(1:2, 3:4, 5:6, 7:8)\ncolnames(dat) <- NULL\n\ntt(dat, theme = \"void\") |> \n style_tt(\n line = \"tblr\", line_color = \"white\", line_width = 0.5,\n background = \"blue\", color = \"white\")\n\n \n\n \n \n \n tinytable_wteljnshus2qywocge0c\n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 1\n 3\n 5\n 7\n \n \n 2\n 4\n 6\n 8",
+ "text": "The style_tt function allows us to customize the borders that surround eacell of a table, as well horizontal and vertical rules. To control these lines, we use the line, line_width, and line_color arguments. Here’s a brief overview of each of these arguments:\n\nline: This argument specifies where solid lines should be drawn. It is a string that can consist of the following characters:\n\n\"t\": Draw a line at the top of the cell, row, or column.\n\"b\": Draw a line at the bottom of the cell, row, or column.\n\"l\": Draw a line at the left side of the cell, row, or column.\n\"r\": Draw a line at the right side of the cell, row, or column.\nYou can combine these characters to draw lines on multiple sides, such as \"tbl\" to draw lines at the top, bottom, and left sides of a cell.\n\nline_width: This argument controls the width of the solid lines in em units (default: 0.1 em). You can adjust this value to make the lines thicker or thinner.\nline_color: Specifies the color of the solid lines. You can use color names, hexadecimal codes, or other color specifications to define the line color.\n\nHere is an example where we draw lines around every border (“t”, “b”, “l”, and “r”) of specified cells.\n\ntt(x, theme = \"void\") |>\n style_tt(\n i = 0:3,\n j = 1:3,\n line = \"tblr\",\n line_width = 0.4,\n line_color = \"orange\")\n\n \n\n \n \n \n tinytable_mqn2c82h1gveayic5jwc\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\nAnd here is an example with horizontal rules:\n\ntt(x, theme = \"void\") |>\n style_tt(i = 0, line = \"t\", line_color = \"orange\", line_width = 0.4) |>\n style_tt(i = 0, line = \"b\", line_color = \"purple\", line_width = 0.2) |>\n style_tt(i = 4, line = \"b\", line_color = \"orange\", line_width = 0.4)\n\n \n\n \n \n \n tinytable_1eailt87vh0ce7814yei\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n \n \n \n \n\n \n\n \n\n\n\n\n\ndat <- data.frame(1:2, 3:4, 5:6, 7:8)\ncolnames(dat) <- NULL\n\ntt(dat, theme = \"void\") |> \n style_tt(\n line = \"tblr\", line_color = \"white\", line_width = 0.5,\n background = \"blue\", color = \"white\")\n\n \n\n \n \n \n tinytable_f38goy17tj2rucuib2tq\n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n 1\n 3\n 5\n 7\n \n \n 2\n 4\n 6\n 8",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
@@ -1026,7 +1026,7 @@
"href": "vignettes/style.html#cell-padding",
"title": "Style",
"section": "",
- "text": "There is no argument in style_tt() to control the padding of cells. Thankfully, this is easy to control using CSS and tabularray options:\n\ntt(x) |> style_tt(\n i = 1:5,\n bootstrap_css = \"padding-right: .2em; padding-top: 2em;\",\n tabularray_inner = \"rowsep={2em}, colsep = {.2em}\"\n)\n\n \n\n \n \n \n tinytable_wfra9avyxg1flyklah0i\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
+ "text": "There is no argument in style_tt() to control the padding of cells. Thankfully, this is easy to control using CSS and tabularray options:\n\ntt(x) |> style_tt(\n i = 1:5,\n bootstrap_css = \"padding-right: .2em; padding-top: 2em;\",\n tabularray_inner = \"rowsep={2em}, colsep = {.2em}\"\n)\n\n \n\n \n \n \n tinytable_k9d1irb7u4vl61k01hry\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 \n 6\n 160\n 110\n 3.9 \n \n \n 21 \n 6\n 160\n 110\n 3.9 \n \n \n 22.8\n 4\n 108\n 93\n 3.85\n \n \n 21.4\n 6\n 258\n 110\n 3.08",
"crumbs": [
"Tutorial (PDF)",
"Tutorial",
diff --git a/vignettes/custom.html b/vignettes/custom.html
index 4fcbf31d..ffe5c5da 100644
--- a/vignettes/custom.html
+++ b/vignettes/custom.html
@@ -414,9 +414,9 @@ Bootstrap classes
- tinytable_3e0u7g9b9p5ddva6xk1u
+ tinytable_h0oen9cakfq5ntbl3a1r
@@ -434,7 +434,7 @@ Bootstrap classes
-
+
@@ -480,12 +480,12 @@ Bootstrap classes
@@ -543,9 +543,9 @@ Bootstrap classes
- tinytable_530vwuanroz6wim1q7mw
+ tinytable_boulqpedg1wcjbgwsi3x
@@ -563,7 +563,7 @@ Bootstrap classes
-
+
@@ -609,12 +609,12 @@ Bootstrap classes
@@ -675,10 +675,10 @@ CSS declarations
- tinytable_nus0g3m796xljgoalz2k
+ tinytable_b7n93jhgvttkqevwvyk7
@@ -696,7 +696,7 @@ CSS declarations
-
+
@@ -742,12 +742,12 @@ CSS declarations
@@ -849,10 +849,10 @@ CSS rules
- tinytable_2ns30eohq27xcf8xxv67
+ tinytable_p83rtkjy84s8neaow42f
@@ -432,7 +432,7 @@ Numbers, dates,
-
+
@@ -447,19 +447,19 @@ Numbers, dates,
143002 |
1.43 |
- 1971-09-09 |
+ 1972-08-03 |
True |
201399 |
201.4 |
- 1972-09-27 |
+ 1971-06-10 |
True |
100188 |
0.13 |
- 1970-05-10 |
+ 1970-03-19 |
False |
@@ -467,12 +467,12 @@ Numbers, dates,
@@ -538,9 +538,9 @@ Numbers, dates,
- tinytable_j57ukfsng7a19s4dneoj
+ tinytable_5kx6pzxuuwsqi3hm8fa3
@@ -558,7 +558,7 @@ Numbers, dates,
-
+
@@ -573,19 +573,19 @@ Numbers, dates,
143 002,21 |
1.4 |
- September 09 1971 |
+ August 03 1972 |
True |
201 399,18 |
201.4 |
- September 27 1972 |
+ June 10 1971 |
True |
100 188,39 |
0.1 |
- May 10 1970 |
+ March 19 1970 |
False |
@@ -593,12 +593,12 @@ Numbers, dates,
@@ -661,9 +661,9 @@ Numbers, dates,
- tinytable_7drb9moylxd2kx9pmvaa
+ tinytable_njeyeduglos52zaj3es6
@@ -681,7 +681,7 @@ Numbers, dates,
-
+
@@ -717,12 +717,12 @@ Numbers, dates,
@@ -796,9 +796,9 @@ Significan
- tinytable_ki99hrfy8a8mqlri9h0x
+ tinytable_mudcqalo09029rrym1av
@@ -816,7 +816,7 @@ Significan
-
+
@@ -836,12 +836,12 @@ Significan
@@ -894,9 +894,9 @@ Significan
- tinytable_3j2uc0mee8152dh67895
+ tinytable_dhbbxg7t0zf74pn7i3y6
@@ -914,7 +914,7 @@ Significan
-
+
@@ -934,12 +934,12 @@ Significan
@@ -994,9 +994,9 @@ Significan
- tinytable_adl4ehwmivgwh3wp6qe7
+ tinytable_raglvjouralgseapuonj
@@ -1014,7 +1014,7 @@ Significan
-
+
@@ -1034,12 +1034,12 @@ Significan
@@ -1097,9 +1097,9 @@ Replacement
- tinytable_0xszfelbkhjqs051awux
+ tinytable_s0rwxv2oucjx9iubssmy
@@ -1117,7 +1117,7 @@ Replacement
-
+
@@ -1144,12 +1144,12 @@ Replacement
@@ -1200,9 +1200,9 @@ Replacement
- tinytable_w3etbtsb7c9rusa3i2vb
+ tinytable_xtupgi89ycb7mt0jvi6e
@@ -1220,7 +1220,7 @@ Replacement
-
+
@@ -1247,12 +1247,12 @@ Replacement
@@ -1303,9 +1303,9 @@ Replacement
- tinytable_4zb2jhv6yu413z1yh0tx
+ tinytable_pzinpoepdfoo2pgxz4ib
@@ -1323,7 +1323,7 @@ Replacement
-
+
@@ -1350,12 +1350,12 @@ Replacement
@@ -1411,9 +1411,9 @@ Replacement
- tinytable_9thjshodw1t66m3u1gm0
+ tinytable_07ttjjstxh72pmeltemt
@@ -1431,7 +1431,7 @@ Replacement
-
+
@@ -1466,12 +1466,12 @@ Replacement
@@ -1533,9 +1533,9 @@ Escape special c
- tinytable_x77dgundaipxuftz6658
+ tinytable_cw3khercyr0a6dvvyzdc
@@ -1553,7 +1553,7 @@ Escape special c
-
+
@@ -1580,12 +1580,12 @@ Escape special c
@@ -1656,10 +1656,10 @@ Markdown
- tinytable_tldwof2xz3yatnu1bfcw
+ tinytable_vq1glx30pwodcqutyctr
@@ -1677,7 +1677,7 @@ Markdown
-
+
@@ -1697,12 +1697,12 @@ Markdown
@@ -1788,9 +1788,9 @@ Markdown
- tinytable_295fmu5lmillx49gx8d7
+ tinytable_eeghkpijyvsrwrhemiyi
@@ -1808,7 +1808,7 @@ Markdown
-
Vincent sometimes contributes to these R packages.
+ Vincent sometimes contributes to these R packages.
@@ -1867,12 +1867,12 @@ Markdown
@@ -1931,9 +1931,9 @@ Custom functions
- tinytable_8iuc2w6mh3mrs6lu28tm
+ tinytable_o79k7x3zi57wlca6whty
@@ -1951,7 +1951,7 @@ Custom functions
-
+
@@ -1997,12 +1997,12 @@ Custom functions
@@ -2074,9 +2074,9 @@ Custom functions
- tinytable_vwpmgeuoucadxk58xxyt
+ tinytable_o6p8muuka98snahy2hgz
@@ -2094,7 +2094,7 @@ Custom functions
-
+
@@ -2140,12 +2140,12 @@ Custom functions
@@ -2208,9 +2208,9 @@ Quarto data process
- tinytable_s9wfml8sl6w07x3vpglf
+ tinytable_c6de5e4vfcv9x9cptcut
@@ -2228,7 +2228,7 @@ Quarto data process
-
+
@@ -2247,12 +2247,12 @@ Quarto data process
@@ -2309,9 +2309,9 @@ Quarto data process
- tinytable_tkwcv196f0jyrcz3jja5
+ tinytable_bjujyq1zga0bfaifhmj5
@@ -2329,7 +2329,7 @@ Quarto data process
-
+
@@ -2348,12 +2348,12 @@ Quarto data process
@@ -2413,9 +2413,9 @@ Quarto data process
- tinytable_kqgav0azp3b8n6eaw0f1
+ tinytable_wk8vy50ctnm3ee6f3fa6
@@ -2434,7 +2434,7 @@ Quarto data process