diff --git a/CITATION.html b/CITATION.html index 338de9e9..dbaf68f5 100644 --- a/CITATION.html +++ b/CITATION.html @@ -124,6 +124,10 @@
  • Customization +
  • +
  • + + Available Options
  • diff --git a/LICENSE.html b/LICENSE.html index 052e44b7..c4f1b78b 100644 --- a/LICENSE.html +++ b/LICENSE.html @@ -125,6 +125,10 @@
  • Customization +
  • +
  • + + Available Options
  • diff --git a/NEWS.html b/NEWS.html index e1385337..10dd8353 100644 --- a/NEWS.html +++ b/NEWS.html @@ -125,6 +125,10 @@
  • Customization +
  • +
  • + + Available Options
  • diff --git a/freeze.rds b/freeze.rds index bc1eedf8..649f4152 100644 Binary files a/freeze.rds and b/freeze.rds differ diff --git a/index.html b/index.html index d6cb4dbc..847f95e2 100644 --- a/index.html +++ b/index.html @@ -157,6 +157,10 @@
  • Customization +
  • +
  • + + Available Options
  • diff --git a/man/format_tt.html b/man/format_tt.html index f084f4b5..04483247 100644 --- a/man/format_tt.html +++ b/man/format_tt.html @@ -159,6 +159,10 @@
  • Customization +
  • +
  • + + Available Options
  • @@ -397,23 +401,23 @@

    Usage

    x, i = NULL, j = NULL, - digits = getOption("tinytable_format_digits", default = NULL), - num_fmt = getOption("tinytable_format_num_fmt", default = "significant"), - num_zero = getOption("tinytable_format_num_zero", default = FALSE), - num_suffix = getOption("tinytable_format_num_suffix", default = FALSE), - num_mark_big = getOption("tinytable_format_num_mark_big", default = ""), - num_mark_dec = getOption("tinytable_format_num_mark_dec", default = getOption("OutDec", - default = ".")), - date = getOption("tinytable_format_date", default = "%Y-%m-%d"), - bool = getOption("tinytable_format_bool", default = function(column) + digits = get_option("tinytable_format_digits", default = NULL), + num_fmt = get_option("tinytable_format_num_fmt", default = "significant"), + num_zero = get_option("tinytable_format_num_zero", default = FALSE), + num_suffix = get_option("tinytable_format_num_suffix", default = FALSE), + num_mark_big = get_option("tinytable_format_num_mark_big", default = ""), + num_mark_dec = get_option("tinytable_format_num_mark_dec", default = + getOption("OutDec", default = ".")), + date = get_option("tinytable_format_date", default = "%Y-%m-%d"), + bool = get_option("tinytable_format_bool", default = function(column) tools::toTitleCase(tolower(column))), - other = getOption("tinytable_format_other", default = as.character), - replace = getOption("tinytable_format_replace", default = TRUE), - escape = getOption("tinytable_format_escape", default = FALSE), - markdown = getOption("tinytable_format_markdown", default = FALSE), - quarto = getOption("tinytable_format_quarto", default = FALSE), - fn = getOption("tinytable_format_fn", default = NULL), - sprintf = getOption("tinytable_format_sprintf", default = NULL), + other = get_option("tinytable_format_other", default = as.character), + replace = get_option("tinytable_format_replace", default = TRUE), + escape = get_option("tinytable_format_escape", default = FALSE), + markdown = get_option("tinytable_format_markdown", default = FALSE), + quarto = get_option("tinytable_format_quarto", default = FALSE), + fn = get_option("tinytable_format_fn", default = NULL), + sprintf = get_option("tinytable_format_sprintf", default = NULL), ... ) @@ -617,19 +621,6 @@

    Value

    Global options

    -Row names -

    -

    When 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:

    -
    -
    options(tinytable_tt_rownames = TRUE)
    -
    -x <- mtcars[1:3, 1:3]
    -tt(x)
    -
    -options(tinytable_tt_rownames = FALSE)
    -
    -
    -

    Quarto data processing

    The format_tt(quarto=TRUE) argument activates Quarto data processing for specific cells. This funcationality comes with a few warnings:

    @@ -663,10 +654,18 @@

    • -

      options(tinytable_save_pdf_clean = TRUE) deletes temporary and log files.

      +

      options(tinytable_pdf_clean = TRUE) deletes temporary and log files.

      +
    • +
    • +

      options(tinytable_pdf_engine = “xelatex”): "xelatex", "pdflatex", "lualatex"

    • +
    +

    +MARKDOWN +

    +
    • -

      options(tinytable_save_pdf_engine = “xelatex”): "xelatex", "pdflatex", "lualatex"

      +

      options(tinytable_markdown_hlines = TRUE) sets whether gridlines are included in markdown tables. This should be true for docx conversion.

    @@ -687,12 +686,12 @@

    Examples

    - +
    @@ -746,15 +745,15 @@

    Examples

    - + - - + + - + @@ -768,12 +767,12 @@

    Examples

    -
    10 000 10 00110 000
    9 999 9 99810 00010 000
    9 99710 000 10 000
    +
    @@ -847,12 +846,12 @@

    Examples

    -
    +
    @@ -938,12 +937,12 @@

    Examples

    -
    +
    @@ -1011,12 +1010,12 @@

    Examples

    -
    +
    @@ -1084,12 +1083,12 @@

    Examples

    -
    +
    @@ -1168,12 +1167,12 @@

    Examples

    -
    +
    diff --git a/man/group_tt.html b/man/group_tt.html index 7a815065..2c11991f 100644 --- a/man/group_tt.html +++ b/man/group_tt.html @@ -159,6 +159,10 @@
  • Customization +
  • +
  • + + Available Options
  • @@ -478,12 +482,12 @@

    Examples

    -
  • +
    @@ -652,12 +656,12 @@

    Examples

    -
    +
    @@ -849,12 +853,12 @@

    Examples

    -
    +
    @@ -1039,12 +1043,12 @@

    Examples

    -
    Hamburgers
    +
    diff --git a/man/plot_tt.html b/man/plot_tt.html index 9f221396..114168f6 100644 --- a/man/plot_tt.html +++ b/man/plot_tt.html @@ -125,6 +125,10 @@
  • Customization +
  • +
  • + + Available Options
  • diff --git a/man/print.tinytable.html b/man/print.tinytable.html index 653268ba..faf00ded 100644 --- a/man/print.tinytable.html +++ b/man/print.tinytable.html @@ -125,6 +125,10 @@
  • Customization +
  • +
  • + + Available Options
  • @@ -358,7 +362,7 @@

    Description

    Usage

    ## S3 method for class 'tinytable'
    -print(x, output = getOption("tinytable_print_output", default = NULL), ...)
    +print(x, output = get_option("tinytable_print_output", default = NULL), ...)
     
    diff --git a/man/rbind2-tinytable-tinytable-method.html b/man/rbind2-tinytable-tinytable-method.html index 575e27f1..2088777f 100644 --- a/man/rbind2-tinytable-tinytable-method.html +++ b/man/rbind2-tinytable-tinytable-method.html @@ -159,6 +159,10 @@
  • Customization +
  • +
  • + + Available Options
  • @@ -483,12 +487,12 @@

    Examples

    -
  • Foo
    +
    @@ -599,12 +603,12 @@

    Examples

    -
    Combine two tiny tables.
    +
    @@ -716,12 +720,12 @@

    Examples

    -
    Combine two tiny tables.
    +
    @@ -826,12 +830,12 @@

    Examples

    -
    Combine two tiny tables.
    +
    diff --git a/man/save_tt.html b/man/save_tt.html index 64b1791d..416e93bd 100644 --- a/man/save_tt.html +++ b/man/save_tt.html @@ -159,6 +159,10 @@
  • Customization +
  • +
  • + + Available Options
  • diff --git a/man/style_tt.html b/man/style_tt.html index db8c151c..bfc0e5ae 100644 --- a/man/style_tt.html +++ b/man/style_tt.html @@ -159,6 +159,10 @@
  • Customization +
  • +
  • + + Available Options
  • diff --git a/man/theme_tt.html b/man/theme_tt.html index a8abb9c6..6ba0bcb0 100644 --- a/man/theme_tt.html +++ b/man/theme_tt.html @@ -159,6 +159,10 @@
  • Customization +
  • +
  • + + Available Options
  • @@ -462,18 +466,38 @@

    Arguments

    • width: A numeric value between 0.01 and 1, representing the proportion of the line width to use

      +
        +
      • +

        Set globally with options(“tinytable_theme_resize_width” = 0.9)

        +
      • +
    • direction: "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

      +
        +
      • +

        Set globally with options(“tinytable_theme_resize_direction” = “down”)

        +
      • +

    multipage

    • rowhead: Non-negative integer. The number of header rows to repeat on each page.

      +
        +
      • +

        Set globally with options(“tinytable_theme_multipage_rowhead” = 1L)

        +
      • +
    • rowfoot: Non-negative integer. The number of footer rows to repeat on each page.

      +
        +
      • +

        Set globally with options(“tinytable_theme_multipage_rowfoot” = 1L)

        +
      • +

    tabular

    @@ -487,6 +511,9 @@

    Arguments

  • "tabularray": Drop all LaTeX dependencies and floating environments, except \begin{tblr}

  • +
  • +

    Set globally with options(“tinytable_theme_tabular_style” = “tblr”)

    +
  • @@ -496,7 +523,7 @@

    Arguments

    horizontal (Typst only): "l", "c", or "r" to align the table horizontally in the page.

    • -

      options(“tinytable_theme_placement_horizontal” = “l”)

      +

      Set globally with options(“tinytable_theme_placement_horizontal” = “l”)

    @@ -504,7 +531,7 @@

    Arguments

    latex_float: String to insert in square brackets after the LaTeX table environment, ex: "H", "htbp". The default value is controlled by a global option:

    • -

      options(“tinytable_theme_placement_latex_float” = “H”)

      +

      Set globally with options(“tinytable_theme_placement_latex_float” = “H”)

    @@ -525,12 +552,12 @@

    Examples

    -
    Combine two tiny tables.
    +
    diff --git a/man/tinytable-package.html b/man/tinytable-package.html index 130b75fc..1a89a75a 100644 --- a/man/tinytable-package.html +++ b/man/tinytable-package.html @@ -123,6 +123,10 @@
  • Customization +
  • +
  • + + Available Options
  • diff --git a/man/tt.html b/man/tt.html index e7d8f441..9e9012b6 100644 --- a/man/tt.html +++ b/man/tt.html @@ -159,6 +159,10 @@
  • Customization +
  • +
  • + + Available Options
  • @@ -417,11 +421,12 @@

    Description

    Usage

    tt(
       x,
    -  digits = getOption("tinytable_tt_digits", default = NULL),
    -  caption = getOption("tinytable_tt_caption", default = NULL),
    -  notes = getOption("tinytable_tt_notes", default = NULL),
    -  width = getOption("tinytable_tt_width", default = NULL),
    -  theme = getOption("tinytable_tt_theme", default = NULL),
    +  digits = get_option("tinytable_tt_digits", default = NULL),
    +  caption = get_option("tinytable_tt_caption", default = NULL),
    +  notes = get_option("tinytable_tt_notes", default = NULL),
    +  width = get_option("tinytable_tt_width", default = NULL),
    +  theme = get_option("tinytable_tt_theme", default = NULL),
    +  rownames = get_option("tinytable_tt_rownames", default = FALSE),
       ...
     )
     
    @@ -509,6 +514,14 @@

    Arguments

  • + + + +
    +rownames + +Logical. If TRUE, rownames are included as the first column +
    @@ -542,19 +555,6 @@

    LaTeX preamble

    Global options

    -Row names -

    -

    When 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:

    -
    -
    options(tinytable_tt_rownames = TRUE)
    -
    -x <- mtcars[1:3, 1:3]
    -tt(x)
    -
    -options(tinytable_tt_rownames = FALSE)
    -
    -
    -

    Quarto data processing

    The format_tt(quarto=TRUE) argument activates Quarto data processing for specific cells. This funcationality comes with a few warnings:

    @@ -588,10 +588,18 @@

    • -

      options(tinytable_save_pdf_clean = TRUE) deletes temporary and log files.

      +

      options(tinytable_pdf_clean = TRUE) deletes temporary and log files.

      +
    • +
    • +

      options(tinytable_pdf_engine = “xelatex”): "xelatex", "pdflatex", "lualatex"

    • +
    +

    +MARKDOWN +

    +
    • -

      options(tinytable_save_pdf_engine = “xelatex”): "xelatex", "pdflatex", "lualatex"

      +

      options(tinytable_markdown_hlines = TRUE) sets whether gridlines are included in markdown tables. This should be true for docx conversion.

    @@ -608,12 +616,12 @@

    Examples

    - +
    @@ -713,12 +721,12 @@

    Examples

    -
    +
    @@ -941,12 +949,12 @@

    Examples

    -
    +
    diff --git a/quarto_website.yml b/quarto_website.yml index 85fd9852..3db87d35 100644 --- a/quarto_website.yml +++ b/quarto_website.yml @@ -20,6 +20,7 @@ website: - vignettes/plot.qmd - vignettes/theme.qmd - vignettes/custom.qmd + - vignettes/options.qmd - vignettes/faq.qmd - text: Tutorial (PDF) file: vignettes/tinytable_tutorial.pdf diff --git a/search.json b/search.json index 050cb543..508e8f5f 100644 --- a/search.json +++ b/search.json @@ -138,430 +138,339 @@ ] }, { - "objectID": "vignettes/faq.html", - "href": "vignettes/faq.html", - "title": "FAQ", + "objectID": "vignettes/style.html", + "href": "vignettes/style.html", + "title": "Style", "section": "", - "text": "Relative widths tables: table-layout: fixed vs auto.\n\n\n\n\n\n\ntinytable uses the tabularray package from your LaTeX distribution to draw tables. tabularray, in turn, provides special tblr, talltblr, and longtblr environments to display tabular data.\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\\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\nSome users have encountered unexpected spacing behavior when generating tables that are not wrapped in a \\begin{table} environment (ex: multipage or raw tblr).\nOne issue stems from the fact that the \\begin{table} environment resets any spacing commands in the preamble or body by default, such as:\n\\usepackage{setspace}\n\\doublespacing\nThis means that when using theme_tt(\"multipage\") —which does not wrap the table in a table environment— the spacing is not reset, and tables are double spaced. This is not a bug, since double-spacing is in fact what the user requested. Nevertheless, the behavior can seem surprising for those used to the automagical table environment spacing reset.\nOne workaround is to add the following to the document preamble when using multipage/longtblr:\n\\usepackage{etoolbox}\n\\AtBeginEnvironment{longtblr}{\\begin{singlespacing}}\n\\AtEndEnvironment{longtblr}{\\end{singlespacing}}\nExample Quarto doc:\n---\ntitle: longtblr and setspacing\nformat:\n pdf:\n include-in-header:\n - text: |\n % Tinytable preamble\n \\usepackage{tabularray}\n \\usepackage{float}\n \\usepackage{graphicx}\n \\usepackage{codehigh}\n \\usepackage[normalem]{ulem}\n \\UseTblrLibrary{booktabs}\n \\UseTblrLibrary{siunitx}\n \\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline\n {#1}}\n \\newcommand{\\tinytableTabularrayStrikeout}[1]{\\sout{#1}}\n \\NewTableCommand{\\tinytableDefineColor}[3]{\\definecolor{\n #1}{#2}{#3}}\n % Spacing Commands\n \\usepackage{setspace}\n \\doublespacing\n % Fix Spacing in longtblr\n \\usepackage{etoolbox}\n \\AtBeginEnvironment{longtblr}{\\begin{singlespacing}}\n \\AtEndEnvironment{longtblr}{\\end{singlespacing}}\n---\n\n```{=latex}\n\\begin{longtblr}[ %% tabularray outer open\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nfoo & bar & baz \\\\\nfoo & bar & baz \\\\\nfoo & bar & baz \\\\\n\\bottomrule\n\\end{longtblr}\n```\n\n\n\ntabularray allows very powerful styling and themeing options. See the reference manual for more information.\nFor example, you can change the size of footnotes in all tables of a document with:\n---\nformat: \n pdf:\n keep-tex: true\n header-includes: |\n \\SetTblrStyle{foot}{font=\\LARGE}\n---\n\n```{r}\nlibrary(tinytable)\nlibrary(magrittr)\ntt(head(iris), notes = \"Blah blah\")\n```\n\n\n\nDue to a bug in the upstream package rmarkdown, Quarto or Rmarkdown presentations compiled to Beamer cannot include adequate package loading commands in the preamble automatically. This bug prevents tinytable::usepackage_latex() from modifying the preamble. Here’s a workaround.\nSave this LaTeX code as preamble.tex:\n\\RequirePackage{tabularray}\n\\RequirePackage{booktabs}\n\\RequirePackage{float}\n\\usepackage[normalem]{ulem}\n\\usepackage{graphicx}\n\\UseTblrLibrary{booktabs}\n\\UseTblrLibrary{siunitx}\n\\NewTableCommand{\\tinytableDefineColor}[3]{\\definecolor{#1}{#2}{#3}}\n\\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline{#1}}\n\\newcommand{\\tinytableTabularrayStrikeout}[1]{\\sout{#1}}\nThen, load preamble.tex in your YAML header:\n---\noutput: \n beamer_presentation:\n includes:\n in_header: preamble.tex\n---\nWith these changes, the table should appear with colors as expected.\n\n\n\n\n\n\nDue to a quirk in Quarto reported here, captions in Typst and Quarto documents need to be specified using both the tbl-cap and the label chunk option:\n```{r}\n#| tbl-cap: \"blah blah blah\"\n#| label: tbl-blah\ntinytable::tt(head(iris, 5))\n```\n\n\n\nThe Typst tables created by tinytable are automatically broken across pages with repeated headers. However, in Quarto documents, the Quarto software wraps tables in an non-breakable #figure environment. This can break the display of long tables. One solution is to use a raw Typst code block to set Figures to be breakable:\n---\nformat: typst\n---\n\n```{=typst}\n#show figure: set block(breakable: true)\n```\n\n```{r}\n#| tbl-cap: \"blah blah blah\"\n#| label: tbl-blah\nlibrary(tinytable)\ntt(head(iris, 50))\n```\n\n\n\n\n\n\nThis is an important limitation, but it is difficult to get around. See this issue for discussion: https://github.com/vincentarelbundock/tinytable/issues/125\nUsers can use markdown styling directly in group_tt() to circumvent this. This is documented in the tutorial.\n\n\n\nThese arguments are already implemented in the form of “pseudo-spans”, meaning that we flush the content of adjacent cells, but do not modify the row or column borders. This is probably adequate for most needs.\nOne alternative would be to remove line segments in finalize_grid(). I tried this but it is tricky and the results were brittle, so I rolled it back. I’m open to considering a PR if someone wants to contribute code, but please discuss the feature design in an issue with me before working on this.\n\n\n\n\n\n\nIn Quarto, it is possible to create a custom crossref type for things like appendix tables. One challenge, is that LaTeX will not allow users to nest a tblr environment, inside a table environment, inside the new environment that Quarto creates for the crossref. Therefore, when rendering a table to LaTeX/PDF, it is important to drop the \\begin{table} environment. This can be done using the theme_tt() function.\nIn the example below, we call theme_tt() explicitly for a single table, but the themes vignette shows how to set a global theme using the tinytable_tt_theme option.\n---\ntitle: \"Crossref Example\"\nformat:\n pdf: default\n html: default\ncrossref:\n custom:\n - kind: float\n key: apptbl\n latex-env: apptbl\n reference-prefix: Table A\n space-before-numbering: false\n latex-list-of-description: Appendix Table\napptbl-cap-location: top\n---\n\nSee @apptbl-testing\n\n::: {#apptbl-testing}\n\n```{r}\nlibrary(tinytable)\n\ntt(mtcars[1:5,]) |> theme_tt(\"tabular\", style = \"tabularray\")\n```\n\nCaption goes here.\n\n:::\n\n\n\nIn some cases, the user wants to print a single table multiple times with different styles in a single HTML document. This will sometimes cause issues, because the style_tt() function inserts several javascript functions to modify the same table, thus creating conflicts. A simple solution is to change the unique ID of the table object manually.\nConsider this RevalJS slideshow in which we sequentially highlight different rows of the data frame:\n---\nformat: revealjs\n---\n\n## Page 1\n\n```{r}\nlibrary(tinytable)\n\ntab <- tt(head(iris))\ntab\n```\n\n## Page 2\n\n```{r}\ntab@id <- \"table_01\"\ntab |> style_tt(i = 3, background = \"skyblue\")\n```\n\n## Page 3\n\n```{r}\ntab@id <- \"table_02\"\ntab |> style_tt(i = 5, background = \"orange\")\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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\ntt(x) |> style_tt(j = \"mpg|drat\", color = \"orange\")\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\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 \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\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 \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\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 \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\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 \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\ntt(dat) |> style_tt(j = 1:3, align = \"lcr\")\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\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 \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\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 \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\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 \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\nHere is the original table for comparison:\n\ntt(x)\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\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 \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\nThe rowspan feature is also useful to create multi-row labels. For example, in this table there is a linebreak, but all the text fits in a single cell:\n\ntab <- data.frame(Letters = c(\"A<br>B\", \"\"), Numbers = c(\"First\", \"Second\"))\n\ntt(tab) |>\n style_tt(bootstrap_class = \"table-bordered\")\n\n\n\n \n\n \n \n \n \n \n \n Letters\n Numbers\n \n \n \n \n \n AB\n First \n \n \n \n Second\n \n \n \n \n\n\n\nNow, we use colspan to ensure that that cells in the first column take up less space and are combined into one:\n\ntt(tab) |>\n style_tt(bootstrap_class = \"table-bordered\") |>\n style_tt(1, 1, rowspan = 2)\n\n\n\n \n\n \n \n \n \n \n \n Letters\n Numbers\n \n \n \n \n \n AB\n First \n \n \n \n Second\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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\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 bootstrap_css = \"padding-right: .2em; padding-top: 2em;\",\n tabularray_inner = \"rowsep={2em}, colsep = {.2em}\"\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\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", - "FAQ" + "Style" ] }, { - "objectID": "vignettes/faq.html#html", - "href": "vignettes/faq.html#html", - "title": "FAQ", + "objectID": "vignettes/style.html#cells-rows-columns", + "href": "vignettes/style.html#cells-rows-columns", + "title": "Style", "section": "", - "text": "Relative widths tables: table-layout: fixed vs auto.", + "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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\ntt(x) |> style_tt(j = \"mpg|drat\", color = \"orange\")\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\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 \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\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 \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", - "FAQ" + "Style" ] }, { - "objectID": "vignettes/faq.html#latex", - "href": "vignettes/faq.html#latex", - "title": "FAQ", + "objectID": "vignettes/style.html#colors", + "href": "vignettes/style.html#colors", + "title": "Style", "section": "", - "text": "tinytable uses the tabularray package from your LaTeX distribution to draw tables. tabularray, in turn, provides special tblr, talltblr, and longtblr environments to display tabular data.\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\\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\nSome users have encountered unexpected spacing behavior when generating tables that are not wrapped in a \\begin{table} environment (ex: multipage or raw tblr).\nOne issue stems from the fact that the \\begin{table} environment resets any spacing commands in the preamble or body by default, such as:\n\\usepackage{setspace}\n\\doublespacing\nThis means that when using theme_tt(\"multipage\") —which does not wrap the table in a table environment— the spacing is not reset, and tables are double spaced. This is not a bug, since double-spacing is in fact what the user requested. Nevertheless, the behavior can seem surprising for those used to the automagical table environment spacing reset.\nOne workaround is to add the following to the document preamble when using multipage/longtblr:\n\\usepackage{etoolbox}\n\\AtBeginEnvironment{longtblr}{\\begin{singlespacing}}\n\\AtEndEnvironment{longtblr}{\\end{singlespacing}}\nExample Quarto doc:\n---\ntitle: longtblr and setspacing\nformat:\n pdf:\n include-in-header:\n - text: |\n % Tinytable preamble\n \\usepackage{tabularray}\n \\usepackage{float}\n \\usepackage{graphicx}\n \\usepackage{codehigh}\n \\usepackage[normalem]{ulem}\n \\UseTblrLibrary{booktabs}\n \\UseTblrLibrary{siunitx}\n \\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline\n {#1}}\n \\newcommand{\\tinytableTabularrayStrikeout}[1]{\\sout{#1}}\n \\NewTableCommand{\\tinytableDefineColor}[3]{\\definecolor{\n #1}{#2}{#3}}\n % Spacing Commands\n \\usepackage{setspace}\n \\doublespacing\n % Fix Spacing in longtblr\n \\usepackage{etoolbox}\n \\AtBeginEnvironment{longtblr}{\\begin{singlespacing}}\n \\AtEndEnvironment{longtblr}{\\end{singlespacing}}\n---\n\n```{=latex}\n\\begin{longtblr}[ %% tabularray outer open\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nfoo & bar & baz \\\\\nfoo & bar & baz \\\\\nfoo & bar & baz \\\\\n\\bottomrule\n\\end{longtblr}\n```\n\n\n\ntabularray allows very powerful styling and themeing options. See the reference manual for more information.\nFor example, you can change the size of footnotes in all tables of a document with:\n---\nformat: \n pdf:\n keep-tex: true\n header-includes: |\n \\SetTblrStyle{foot}{font=\\LARGE}\n---\n\n```{r}\nlibrary(tinytable)\nlibrary(magrittr)\ntt(head(iris), notes = \"Blah blah\")\n```\n\n\n\nDue to a bug in the upstream package rmarkdown, Quarto or Rmarkdown presentations compiled to Beamer cannot include adequate package loading commands in the preamble automatically. This bug prevents tinytable::usepackage_latex() from modifying the preamble. Here’s a workaround.\nSave this LaTeX code as preamble.tex:\n\\RequirePackage{tabularray}\n\\RequirePackage{booktabs}\n\\RequirePackage{float}\n\\usepackage[normalem]{ulem}\n\\usepackage{graphicx}\n\\UseTblrLibrary{booktabs}\n\\UseTblrLibrary{siunitx}\n\\NewTableCommand{\\tinytableDefineColor}[3]{\\definecolor{#1}{#2}{#3}}\n\\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline{#1}}\n\\newcommand{\\tinytableTabularrayStrikeout}[1]{\\sout{#1}}\nThen, load preamble.tex in your YAML header:\n---\noutput: \n beamer_presentation:\n includes:\n in_header: preamble.tex\n---\nWith these changes, the table should appear with colors as expected.", + "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 \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\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", - "FAQ" + "Style" ] }, { - "objectID": "vignettes/faq.html#typst", - "href": "vignettes/faq.html#typst", - "title": "FAQ", + "objectID": "vignettes/style.html#alignment", + "href": "vignettes/style.html#alignment", + "title": "Style", "section": "", - "text": "Due to a quirk in Quarto reported here, captions in Typst and Quarto documents need to be specified using both the tbl-cap and the label chunk option:\n```{r}\n#| tbl-cap: \"blah blah blah\"\n#| label: tbl-blah\ntinytable::tt(head(iris, 5))\n```\n\n\n\nThe Typst tables created by tinytable are automatically broken across pages with repeated headers. However, in Quarto documents, the Quarto software wraps tables in an non-breakable #figure environment. This can break the display of long tables. One solution is to use a raw Typst code block to set Figures to be breakable:\n---\nformat: typst\n---\n\n```{=typst}\n#show figure: set block(breakable: true)\n```\n\n```{r}\n#| tbl-cap: \"blah blah blah\"\n#| label: tbl-blah\nlibrary(tinytable)\ntt(head(iris, 50))\n```", + "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 \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\ntt(dat) |> style_tt(j = 1:3, align = \"lcr\")\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\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 \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", - "FAQ" + "Style" ] }, { - "objectID": "vignettes/faq.html#markdown", - "href": "vignettes/faq.html#markdown", - "title": "FAQ", + "objectID": "vignettes/style.html#font-size", + "href": "vignettes/style.html#font-size", + "title": "Style", "section": "", - "text": "This is an important limitation, but it is difficult to get around. See this issue for discussion: https://github.com/vincentarelbundock/tinytable/issues/125\nUsers can use markdown styling directly in group_tt() to circumvent this. This is documented in the tutorial.\n\n\n\nThese arguments are already implemented in the form of “pseudo-spans”, meaning that we flush the content of adjacent cells, but do not modify the row or column borders. This is probably adequate for most needs.\nOne alternative would be to remove line segments in finalize_grid(). I tried this but it is tricky and the results were brittle, so I rolled it back. I’m open to considering a PR if someone wants to contribute code, but please discuss the feature design in an issue with me before working on this.", + "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 \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", - "FAQ" + "Style" ] }, { - "objectID": "vignettes/faq.html#quarto", - "href": "vignettes/faq.html#quarto", - "title": "FAQ", + "objectID": "vignettes/style.html#spanning-cells-merging-cells", + "href": "vignettes/style.html#spanning-cells-merging-cells", + "title": "Style", "section": "", - "text": "In Quarto, it is possible to create a custom crossref type for things like appendix tables. One challenge, is that LaTeX will not allow users to nest a tblr environment, inside a table environment, inside the new environment that Quarto creates for the crossref. Therefore, when rendering a table to LaTeX/PDF, it is important to drop the \\begin{table} environment. This can be done using the theme_tt() function.\nIn the example below, we call theme_tt() explicitly for a single table, but the themes vignette shows how to set a global theme using the tinytable_tt_theme option.\n---\ntitle: \"Crossref Example\"\nformat:\n pdf: default\n html: default\ncrossref:\n custom:\n - kind: float\n key: apptbl\n latex-env: apptbl\n reference-prefix: Table A\n space-before-numbering: false\n latex-list-of-description: Appendix Table\napptbl-cap-location: top\n---\n\nSee @apptbl-testing\n\n::: {#apptbl-testing}\n\n```{r}\nlibrary(tinytable)\n\ntt(mtcars[1:5,]) |> theme_tt(\"tabular\", style = \"tabularray\")\n```\n\nCaption goes here.\n\n:::\n\n\n\nIn some cases, the user wants to print a single table multiple times with different styles in a single HTML document. This will sometimes cause issues, because the style_tt() function inserts several javascript functions to modify the same table, thus creating conflicts. A simple solution is to change the unique ID of the table object manually.\nConsider this RevalJS slideshow in which we sequentially highlight different rows of the data frame:\n---\nformat: revealjs\n---\n\n## Page 1\n\n```{r}\nlibrary(tinytable)\n\ntab <- tt(head(iris))\ntab\n```\n\n## Page 2\n\n```{r}\ntab@id <- \"table_01\"\ntab |> style_tt(i = 3, background = \"skyblue\")\n```\n\n## Page 3\n\n```{r}\ntab@id <- \"table_02\"\ntab |> style_tt(i = 5, background = \"orange\")\n```", + "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 \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\nHere is the original table for comparison:\n\ntt(x)\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\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 \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\nThe rowspan feature is also useful to create multi-row labels. For example, in this table there is a linebreak, but all the text fits in a single cell:\n\ntab <- data.frame(Letters = c(\"A<br>B\", \"\"), Numbers = c(\"First\", \"Second\"))\n\ntt(tab) |>\n style_tt(bootstrap_class = \"table-bordered\")\n\n\n\n \n\n \n \n \n \n \n \n Letters\n Numbers\n \n \n \n \n \n AB\n First \n \n \n \n Second\n \n \n \n \n\n\n\nNow, we use colspan to ensure that that cells in the first column take up less space and are combined into one:\n\ntt(tab) |>\n style_tt(bootstrap_class = \"table-bordered\") |>\n style_tt(1, 1, rowspan = 2)\n\n\n\n \n\n \n \n \n \n \n \n Letters\n Numbers\n \n \n \n \n \n AB\n First \n \n \n \n Second", "crumbs": [ "Tutorial (PDF)", "Tutorial", - "FAQ" + "Style" ] }, { - "objectID": "vignettes/group.html", - "href": "vignettes/group.html", - "title": "Groups and labels", + "objectID": "vignettes/style.html#headers", + "href": "vignettes/style.html#headers", + "title": "Style", "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 \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\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\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\ntt(head(iris)) |>\n group_tt(i = list(\"After 1a\" = 2, \"After 1b\" = 2, \"After 5\" = 6))\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\ntt(head(iris)) |>\n group_tt(i = list(\"After 0\" = 1))\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\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 \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\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 \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\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 \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\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 \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 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 \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\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 \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\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 \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", - "Group labels" + "Style" ] }, { - "objectID": "vignettes/group.html#rows", - "href": "vignettes/group.html#rows", - "title": "Groups and labels", + "objectID": "vignettes/style.html#conditional-styling", + "href": "vignettes/style.html#conditional-styling", + "title": "Style", "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 \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\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\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\ntt(head(iris)) |>\n group_tt(i = list(\"After 1a\" = 2, \"After 1b\" = 2, \"After 5\" = 6))\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\ntt(head(iris)) |>\n group_tt(i = list(\"After 0\" = 1))\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\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 \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": "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 \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", - "Group labels" + "Style" ] }, { - "objectID": "vignettes/group.html#columns", - "href": "vignettes/group.html#columns", - "title": "Groups and labels", + "objectID": "vignettes/style.html#vectorized-styling-heatmaps", + "href": "vignettes/style.html#vectorized-styling-heatmaps", + "title": "Style", "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 \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\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 \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\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 \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 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 \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\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 \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\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 \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", - "Group labels" + "Style" ] }, { - "objectID": "vignettes/plot.html", - "href": "vignettes/plot.html", - "title": "Plots and images", + "objectID": "vignettes/style.html#lines-borders", + "href": "vignettes/style.html#lines-borders", + "title": "Style", "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 \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\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 \n \n \n \n \n R\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 \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\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 \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\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 \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\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 \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\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 \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 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 \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\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 \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\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 \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", - "Plots and images" + "Style" ] }, { - "objectID": "vignettes/plot.html#inserting-images-in-tables", - "href": "vignettes/plot.html#inserting-images-in-tables", - "title": "Plots and images", + "objectID": "vignettes/style.html#cell-padding-height-and-width", + "href": "vignettes/style.html#cell-padding-height-and-width", + "title": "Style", "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 \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\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 \n \n \n \n \n R", + "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 bootstrap_css = \"padding-right: .2em; padding-top: 2em;\",\n tabularray_inner = \"rowsep={2em}, colsep = {.2em}\"\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", - "Plots and images" + "Style" ] }, { - "objectID": "vignettes/plot.html#inline-plots", - "href": "vignettes/plot.html#inline-plots", - "title": "Plots and images", + "objectID": "vignettes/style.html#markdown-and-word", + "href": "vignettes/style.html#markdown-and-word", + "title": "Style", "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 \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\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 \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\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 \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\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 \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": "Styling 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", - "Plots and images" + "Style" ] }, { - "objectID": "vignettes/plot.html#fontawesome", - "href": "vignettes/plot.html#fontawesome", - "title": "Plots and images", + "objectID": "vignettes/theme.html", + "href": "vignettes/theme.html", + "title": "Themes", "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 \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": "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 \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\ntt(x) |> theme_tt(\"striped\")\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\ntt(x, theme = \"grid\")\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\ntt(x, theme = \"bootstrap\")\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\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 \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\ntt(mtcars[1:3, 1:3])\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\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{tabular}{lllll}\n\\hline\nmpg & cyl & disp & hp & drat \\\\ \\hline\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\\hline\n\\end{tabular} \n\n\n\n\n\nLaTeX only.\n\n\n\nLaTeX only.\n\n\n\nLaTeX only.", "crumbs": [ "Tutorial (PDF)", "Tutorial", - "Plots and images" + "Themes" ] }, { - "objectID": "man/print.tinytable.html", - "href": "man/print.tinytable.html", - "title": "tinytable", + "objectID": "vignettes/theme.html#visual-themes", + "href": "vignettes/theme.html#visual-themes", + "title": "Themes", "section": "", - "text": "This function is called automatically by R whenever a tinytable object is anprinted to the console or in an HTML viewer pane.\n\n\n\n## S3 method for class 'tinytable'\nprint(x, output = getOption(\"tinytable_print_output\", default = NULL), ...)\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\noutput\n\n\nformat in which a Tiny Table is printed: NULL or one of “latex”, “markdown”, “html”, “typst”, “dataframe”. If NULL, the output is chosen based on these rules:\n\n\nWhen called from a script in non-interactive mode, the default is \"markdown\" (interactive() == FALSE).\n\n\nWhen called interactively in RStudio, the default is to display an HTML table in the viewer pane.\n\n\nWhen called interactively in another development environment, the default is \"markdown\".\n\n\nThe default print output can be changed for an entire R session by calling: options(tinytable_print_output = “html”)\n\n\nThe default print output can be changed for a single tinytable object by modifying the output S4 slot.\n\n\n\n\n\n\n…\n\n\nOther arguments are ignored.\n\n\n\n\n\n\nlaunch a browser window or cat() the table to console.", + "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 \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\ntt(x) |> theme_tt(\"striped\")\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\ntt(x, theme = \"grid\")\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\ntt(x, theme = \"bootstrap\")\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)", - "Functions", - "`print`" + "Tutorial", + "Themes" ] }, { - "objectID": "man/print.tinytable.html#print-display-or-convert-a-tinytable-object", - "href": "man/print.tinytable.html#print-display-or-convert-a-tinytable-object", - "title": "tinytable", + "objectID": "vignettes/theme.html#custom-themes", + "href": "vignettes/theme.html#custom-themes", + "title": "Themes", "section": "", - "text": "This function is called automatically by R whenever a tinytable object is anprinted to the console or in an HTML viewer pane.\n\n\n\n## S3 method for class 'tinytable'\nprint(x, output = getOption(\"tinytable_print_output\", default = NULL), ...)\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\noutput\n\n\nformat in which a Tiny Table is printed: NULL or one of “latex”, “markdown”, “html”, “typst”, “dataframe”. If NULL, the output is chosen based on these rules:\n\n\nWhen called from a script in non-interactive mode, the default is \"markdown\" (interactive() == FALSE).\n\n\nWhen called interactively in RStudio, the default is to display an HTML table in the viewer pane.\n\n\nWhen called interactively in another development environment, the default is \"markdown\".\n\n\nThe default print output can be changed for an entire R session by calling: options(tinytable_print_output = “html”)\n\n\nThe default print output can be changed for a single tinytable object by modifying the output S4 slot.\n\n\n\n\n\n\n…\n\n\nOther arguments are ignored.\n\n\n\n\n\n\nlaunch a browser window or cat() the table to console.", + "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 \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\ntt(mtcars[1:3, 1:3])\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\noptions(tinytable_tt_theme = NULL)", "crumbs": [ "Tutorial (PDF)", - "Functions", - "`print`" + "Tutorial", + "Themes" ] }, { - "objectID": "man/style_tt.html", - "href": "man/style_tt.html", - "title": "tinytable", + "objectID": "vignettes/theme.html#tabular", + "href": "vignettes/theme.html#tabular", + "title": "Themes", "section": "", - "text": "Style a Tiny Table\n\n\n\nstyle_tt(\n x,\n i = NULL,\n j = NULL,\n bold = FALSE,\n italic = FALSE,\n monospace = FALSE,\n underline = FALSE,\n strikeout = FALSE,\n color = NULL,\n background = NULL,\n fontsize = NULL,\n align = NULL,\n alignv = NULL,\n colspan = NULL,\n rowspan = NULL,\n indent = 0,\n line = NULL,\n line_color = \"black\",\n line_width = 0.1,\n finalize = NULL,\n tabularray_inner = NULL,\n tabularray_outer = NULL,\n bootstrap_class = NULL,\n bootstrap_css = NULL,\n bootstrap_css_rule = NULL,\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA table object created by tt().\n\n\n\n\ni\n\n\nRow indices where the styling should be applied. Can be a single value or a vector. i=0 is the header, and negative values are higher level headers. If colspan is used, i must be of length 1.\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\nbold\n\n\nLogical; if TRUE, text is styled in bold.\n\n\n\n\nitalic\n\n\nLogical; if TRUE, text is styled in italic.\n\n\n\n\nmonospace\n\n\nLogical; if TRUE, text is styled in monospace font.\n\n\n\n\nunderline\n\n\nLogical; if TRUE, text is underlined.\n\n\n\n\nstrikeout\n\n\nLogical; if TRUE, text has a strike through line.\n\n\n\n\ncolor\n\n\nText color. There are several ways to specify colors, depending on the output format.\n\n\nHTML:\n\n\nHex code composed of # and 6 characters, ex: #CC79A7.\n\n\nKeywords: black, silver, gray, white, maroon, red, purple, fuchsia, green, lime, olive, yellow, navy, blue, teal, aqua\n\n\n\n\nLaTeX:\n\n\nHex code composed of # and 6 characters, ex: \"#CC79A7\". See the section below for instructions to add in LaTeX preambles.\n\n\nKeywords: black, blue, brown, cyan, darkgray, gray, green, lightgray, lime, magenta, olive, orange, pink, purple, red, teal, violet, white, yellow.\n\n\nColor blending using xcolor, ex: white!80!blue, green!20!red’.\n\n\nColor names with luminance levels from the ninecolors package (ex: \"azure4\", \"magenta8\", \"teal2\", \"gray1\", \"olive3\").\n\n\n\n\n\n\n\n\nbackground\n\n\nBackground color. Specified as a color name or hexadecimal code. Can be NULL for default color.\n\n\n\n\nfontsize\n\n\nFont size in em units. Can be NULL for default size.\n\n\n\n\nalign\n\n\nA single character or a string with a number of characters equal to the number of columns in j. Valid characters include ‘c’ (center), ‘l’ (left), ‘r’ (right), ‘d’ (decimal). Decimal alignment is only available in LaTeX via the siunitx package. 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 and j.\n\n\n\n\nalignv\n\n\nA single character specifying vertical alignment. Valid characters include ‘t’ (top), ‘m’ (middle), ‘b’ (bottom).\n\n\n\n\ncolspan\n\n\nNumber of columns a cell should span. i and j must be of length 1.\n\n\n\n\nrowspan\n\n\nNumber of rows a cell should span. i and j must be of length 1.\n\n\n\n\nindent\n\n\nText indentation in em units. Positive values only.\n\n\n\n\nline\n\n\nString determines if solid lines (rules or borders) should be drawn around the cell, row, or column.\n\n\n\"t\": top\n\n\n\"b\": bottom\n\n\n\"l\": left\n\n\n\"r\": right\n\n\nCan be combined such as: \"lbt\" to draw borders at the left, bottom, and top.\n\n\n\n\n\n\nline_color\n\n\nColor of the line. See the color argument for details.\n\n\n\n\nline_width\n\n\nWidth of the line in em units (default: 0.1).\n\n\n\n\nfinalize\n\n\nA function applied to the table object at the very end of table-building, for post-processing. For example, the function could use regular expressions to add LaTeX commands to the text version of the table hosted in x@table_string, or it could programmatically change the caption in x@caption.\n\n\n\n\ntabularray_inner\n\n\nA string that specifies the \"inner\" settings of a tabularray LaTeX table.\n\n\n\n\ntabularray_outer\n\n\nA string that specifies the \"outer\" settings of a tabularray LaTeX table.\n\n\n\n\nbootstrap_class\n\n\nString. Bootstrap table class such as “table”, “table table-dark” or “table table-dark table-hover”. See the bootstrap documentation.\n\n\n\n\nbootstrap_css\n\n\nCharacter vector. CSS style declarations to be applied to every cell defined by i and j (ex: “font-weight: bold”).\n\n\n\n\nbootstrap_css_rule\n\n\nString. Complete CSS rules (with curly braces, semicolon, etc.) that apply to the table class specified by the bootstrap_class argument.\n\n\n\n\n…\n\n\nextra arguments are ignored\n\n\n\n\n\n\nThis function applies styling to a table created by tt(). It allows customization of text style (bold, italic, monospace), text and background colors, font size, cell width, text alignment, column span, and indentation. The function also supports passing native instructions to LaTeX (tabularray) and HTML (bootstrap) formats.\nNote: Markdown and Word tables only support these styles: italic, bold, strikeout. Moreover, the style_tt() function cannot be used to style headers inserted by the group_tt() function; instead, you should style the headers directly in the header definition using markdown syntax: group_tt(i = list(“italic header” = 2)). These limitations are due to the fact that there is no markdown syntax for the other options, and that we create Word documents by converting a markdown table to .docx via the Pandoc software.\n\n\n\nAn object of class tt representing the table.\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\nlibrary(\"tinytable\")\n\n\n\nif (knitr::is_html_output()) options(tinytable_print_output = \"html\")\n\nlibrary(tinytable)\n\ntt(mtcars[1:5, 1:6])\n\n# Alignment\ntt(mtcars[1:5, 1:6]) |> \n style_tt(j = 1:5, align = \"lcccr\")\n\n# Colors and styles\ntt(mtcars[1:5, 1:6]) |> \n style_tt(i = 2:3, background = \"black\", color = \"orange\", bold = TRUE)\n\n# column selection with `j``\ntt(mtcars[1:5, 1:6]) |> \n style_tt(j = 5:6, background = \"pink\")\n\ntt(mtcars[1:5, 1:6]) |>\n style_tt(j = \"drat|wt\", background = \"pink\")\n\ntt(mtcars[1:5, 1:6]) |>\n style_tt(j = c(\"drat\", \"wt\"), background = \"pink\")\n\ntt(mtcars[1:5, 1:6], theme = \"void\") |>\n 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 \ntt(mtcars[1:5, 1:6], theme = \"void\") |>\n style_tt(\n i=0:3,\n j=1:3,\n line=\"tblr\",\n line_width=0.4,\n line_color=\"teal\")\n \ntt(mtcars[1:5, 1:6], theme = \"bootstrap\") |>\n style_tt(\n i = c(2,5),\n j = 3,\n strikeout = TRUE,\n fontsize = 0.7)\n \ntt(mtcars[1:5, 1:6]) |>\n style_tt(bootstrap_class = \"table table-dark table-hover\")\n\n\ninner <- \"\ncolumn{1-4}={halign=c},\nhlines = {fg=white},\nvlines = {fg=white},\ncell{1,6}{odd} = {bg=teal7},\ncell{1,6}{even} = {bg=green7},\ncell{2,4}{1,4} = {bg=red7},\ncell{3,5}{1,4} = {bg=purple7},\ncell{2}{2} = {r=4,c=2}{bg=azure7},\n\"\ntt(mtcars[1:5, 1:4], theme = \"void\") |>\n style_tt(tabularray_inner = inner)", + "text": "The 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{tabular}{lllll}\n\\hline\nmpg & cyl & disp & hp & drat \\\\ \\hline\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\\hline\n\\end{tabular}", "crumbs": [ "Tutorial (PDF)", - "Functions", - "`style_tt`" + "Tutorial", + "Themes" ] }, { - "objectID": "man/style_tt.html#style-a-tiny-table", - "href": "man/style_tt.html#style-a-tiny-table", - "title": "tinytable", + "objectID": "vignettes/theme.html#resize", + "href": "vignettes/theme.html#resize", + "title": "Themes", "section": "", - "text": "Style a Tiny Table\n\n\n\nstyle_tt(\n x,\n i = NULL,\n j = NULL,\n bold = FALSE,\n italic = FALSE,\n monospace = FALSE,\n underline = FALSE,\n strikeout = FALSE,\n color = NULL,\n background = NULL,\n fontsize = NULL,\n align = NULL,\n alignv = NULL,\n colspan = NULL,\n rowspan = NULL,\n indent = 0,\n line = NULL,\n line_color = \"black\",\n line_width = 0.1,\n finalize = NULL,\n tabularray_inner = NULL,\n tabularray_outer = NULL,\n bootstrap_class = NULL,\n bootstrap_css = NULL,\n bootstrap_css_rule = NULL,\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA table object created by tt().\n\n\n\n\ni\n\n\nRow indices where the styling should be applied. Can be a single value or a vector. i=0 is the header, and negative values are higher level headers. If colspan is used, i must be of length 1.\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\nbold\n\n\nLogical; if TRUE, text is styled in bold.\n\n\n\n\nitalic\n\n\nLogical; if TRUE, text is styled in italic.\n\n\n\n\nmonospace\n\n\nLogical; if TRUE, text is styled in monospace font.\n\n\n\n\nunderline\n\n\nLogical; if TRUE, text is underlined.\n\n\n\n\nstrikeout\n\n\nLogical; if TRUE, text has a strike through line.\n\n\n\n\ncolor\n\n\nText color. There are several ways to specify colors, depending on the output format.\n\n\nHTML:\n\n\nHex code composed of # and 6 characters, ex: #CC79A7.\n\n\nKeywords: black, silver, gray, white, maroon, red, purple, fuchsia, green, lime, olive, yellow, navy, blue, teal, aqua\n\n\n\n\nLaTeX:\n\n\nHex code composed of # and 6 characters, ex: \"#CC79A7\". See the section below for instructions to add in LaTeX preambles.\n\n\nKeywords: black, blue, brown, cyan, darkgray, gray, green, lightgray, lime, magenta, olive, orange, pink, purple, red, teal, violet, white, yellow.\n\n\nColor blending using xcolor, ex: white!80!blue, green!20!red’.\n\n\nColor names with luminance levels from the ninecolors package (ex: \"azure4\", \"magenta8\", \"teal2\", \"gray1\", \"olive3\").\n\n\n\n\n\n\n\n\nbackground\n\n\nBackground color. Specified as a color name or hexadecimal code. Can be NULL for default color.\n\n\n\n\nfontsize\n\n\nFont size in em units. Can be NULL for default size.\n\n\n\n\nalign\n\n\nA single character or a string with a number of characters equal to the number of columns in j. Valid characters include ‘c’ (center), ‘l’ (left), ‘r’ (right), ‘d’ (decimal). Decimal alignment is only available in LaTeX via the siunitx package. 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 and j.\n\n\n\n\nalignv\n\n\nA single character specifying vertical alignment. Valid characters include ‘t’ (top), ‘m’ (middle), ‘b’ (bottom).\n\n\n\n\ncolspan\n\n\nNumber of columns a cell should span. i and j must be of length 1.\n\n\n\n\nrowspan\n\n\nNumber of rows a cell should span. i and j must be of length 1.\n\n\n\n\nindent\n\n\nText indentation in em units. Positive values only.\n\n\n\n\nline\n\n\nString determines if solid lines (rules or borders) should be drawn around the cell, row, or column.\n\n\n\"t\": top\n\n\n\"b\": bottom\n\n\n\"l\": left\n\n\n\"r\": right\n\n\nCan be combined such as: \"lbt\" to draw borders at the left, bottom, and top.\n\n\n\n\n\n\nline_color\n\n\nColor of the line. See the color argument for details.\n\n\n\n\nline_width\n\n\nWidth of the line in em units (default: 0.1).\n\n\n\n\nfinalize\n\n\nA function applied to the table object at the very end of table-building, for post-processing. For example, the function could use regular expressions to add LaTeX commands to the text version of the table hosted in x@table_string, or it could programmatically change the caption in x@caption.\n\n\n\n\ntabularray_inner\n\n\nA string that specifies the \"inner\" settings of a tabularray LaTeX table.\n\n\n\n\ntabularray_outer\n\n\nA string that specifies the \"outer\" settings of a tabularray LaTeX table.\n\n\n\n\nbootstrap_class\n\n\nString. Bootstrap table class such as “table”, “table table-dark” or “table table-dark table-hover”. See the bootstrap documentation.\n\n\n\n\nbootstrap_css\n\n\nCharacter vector. CSS style declarations to be applied to every cell defined by i and j (ex: “font-weight: bold”).\n\n\n\n\nbootstrap_css_rule\n\n\nString. Complete CSS rules (with curly braces, semicolon, etc.) that apply to the table class specified by the bootstrap_class argument.\n\n\n\n\n…\n\n\nextra arguments are ignored\n\n\n\n\n\n\nThis function applies styling to a table created by tt(). It allows customization of text style (bold, italic, monospace), text and background colors, font size, cell width, text alignment, column span, and indentation. The function also supports passing native instructions to LaTeX (tabularray) and HTML (bootstrap) formats.\nNote: Markdown and Word tables only support these styles: italic, bold, strikeout. Moreover, the style_tt() function cannot be used to style headers inserted by the group_tt() function; instead, you should style the headers directly in the header definition using markdown syntax: group_tt(i = list(“italic header” = 2)). These limitations are due to the fact that there is no markdown syntax for the other options, and that we create Word documents by converting a markdown table to .docx via the Pandoc software.\n\n\n\nAn object of class tt representing the table.\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\nlibrary(\"tinytable\")\n\n\n\nif (knitr::is_html_output()) options(tinytable_print_output = \"html\")\n\nlibrary(tinytable)\n\ntt(mtcars[1:5, 1:6])\n\n# Alignment\ntt(mtcars[1:5, 1:6]) |> \n style_tt(j = 1:5, align = \"lcccr\")\n\n# Colors and styles\ntt(mtcars[1:5, 1:6]) |> \n style_tt(i = 2:3, background = \"black\", color = \"orange\", bold = TRUE)\n\n# column selection with `j``\ntt(mtcars[1:5, 1:6]) |> \n style_tt(j = 5:6, background = \"pink\")\n\ntt(mtcars[1:5, 1:6]) |>\n style_tt(j = \"drat|wt\", background = \"pink\")\n\ntt(mtcars[1:5, 1:6]) |>\n style_tt(j = c(\"drat\", \"wt\"), background = \"pink\")\n\ntt(mtcars[1:5, 1:6], theme = \"void\") |>\n 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 \ntt(mtcars[1:5, 1:6], theme = \"void\") |>\n style_tt(\n i=0:3,\n j=1:3,\n line=\"tblr\",\n line_width=0.4,\n line_color=\"teal\")\n \ntt(mtcars[1:5, 1:6], theme = \"bootstrap\") |>\n style_tt(\n i = c(2,5),\n j = 3,\n strikeout = TRUE,\n fontsize = 0.7)\n \ntt(mtcars[1:5, 1:6]) |>\n style_tt(bootstrap_class = \"table table-dark table-hover\")\n\n\ninner <- \"\ncolumn{1-4}={halign=c},\nhlines = {fg=white},\nvlines = {fg=white},\ncell{1,6}{odd} = {bg=teal7},\ncell{1,6}{even} = {bg=green7},\ncell{2,4}{1,4} = {bg=red7},\ncell{3,5}{1,4} = {bg=purple7},\ncell{2}{2} = {r=4,c=2}{bg=azure7},\n\"\ntt(mtcars[1:5, 1:4], theme = \"void\") |>\n style_tt(tabularray_inner = inner)", + "text": "LaTeX only.", "crumbs": [ "Tutorial (PDF)", - "Functions", - "`style_tt`" + "Tutorial", + "Themes" ] }, { - "objectID": "man/theme_tt.html", - "href": "man/theme_tt.html", - "title": "tinytable", + "objectID": "vignettes/theme.html#placement", + "href": "vignettes/theme.html#placement", + "title": "Themes", "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\": Remove 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\ntabular\n\n\nstyle:\n\n\n\"tabular\": Drop all LaTeX dependencies and floating environments, except \\begin{tabular}\n\n\n\"tabularray\": Drop all LaTeX dependencies and floating environments, except \\begin{tblr}\n\n\n\n\nplacement\n\n\nhorizontal (Typst only): \"l\", \"c\", or \"r\" to align the table horizontally in the page.\n\n\noptions(“tinytable_theme_placement_horizontal” = “l”)\n\n\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 \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\ntt(x) |> theme_tt(\"striped\")\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# 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": "LaTeX only.", "crumbs": [ "Tutorial (PDF)", - "Functions", - "`theme_tt`" + "Tutorial", + "Themes" ] }, { - "objectID": "man/theme_tt.html#themes-for-tinytable", - "href": "man/theme_tt.html#themes-for-tinytable", - "title": "tinytable", + "objectID": "vignettes/theme.html#multipage", + "href": "vignettes/theme.html#multipage", + "title": "Themes", "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\": Remove 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\ntabular\n\n\nstyle:\n\n\n\"tabular\": Drop all LaTeX dependencies and floating environments, except \\begin{tabular}\n\n\n\"tabularray\": Drop all LaTeX dependencies and floating environments, except \\begin{tblr}\n\n\n\n\nplacement\n\n\nhorizontal (Typst only): \"l\", \"c\", or \"r\" to align the table horizontally in the page.\n\n\noptions(“tinytable_theme_placement_horizontal” = “l”)\n\n\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 \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\ntt(x) |> theme_tt(\"striped\")\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# 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": "LaTeX only.", "crumbs": [ "Tutorial (PDF)", - "Functions", - "`theme_tt`" + "Tutorial", + "Themes" ] }, { - "objectID": "man/plot_tt.html", - "href": "man/plot_tt.html", - "title": "tinytable", + "objectID": "vignettes/format.html", + "href": "vignettes/format.html", + "title": "Formatting", "section": "", - "text": "The plot_tt() function allows for the insertion of images and inline plots into tinytable objects. This function can handle both local and web-based images.\n\n\n\nplot_tt(\n x,\n i = NULL,\n j = NULL,\n fun = NULL,\n data = NULL,\n color = \"black\",\n xlim = NULL,\n height = 1,\n asp = 1/3,\n images = NULL,\n assets = \"tinytable_assets\",\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA tinytable object.\n\n\n\n\ni\n\n\nInteger vector, the row indices where images are to be inserted. If NULL, images will be inserted in all rows.\n\n\n\n\nj\n\n\nInteger vector, the column indices where images are to be inserted. If NULL, images will be inserted in all columns.\n\n\n\n\nfun\n\n\nString or function to generate inline plots.\n\n\nString: \"histogram\", \"density\", \"bar\", \"line\"\n\n\nFunctions that return ggplot2 objects.\n\n\nFunctions that return another function which generates a base R plot, ex: function(x) {function() hist(x)}\n\n\nSee the tutorial on the tinytable website for more information.\n\n\n\n\n\n\ndata\n\n\na list of data frames or vectors to be used by the plotting functions in fun.\n\n\n\n\ncolor\n\n\nstring Name of color to use for inline plots (passed to the col argument base graphics plots in R).\n\n\n\n\nxlim\n\n\nNumeric vector of length 2.\n\n\n\n\nheight\n\n\nNumeric, the height of the images in the table in em units.\n\n\n\n\nasp\n\n\nNumeric, aspect ratio of the plots (height / width).\n\n\n\n\nimages\n\n\nCharacter vector, the paths to the images to be inserted. Paths are relative to the main table file or Quarto (Rmarkdown) document.\n\n\n\n\nassets\n\n\nPath to the directory where generated assets are stored. This path is relative to the location where a table is saved.\n\n\n\n\n…\n\n\nExtra arguments are passed to the function in fun. Important: Custom plotting functions must always have … as an argument.\n\n\n\n\n\n\nThe plot_tt() can insert images and inline plots into tables.\n\n\n\nA modified tinytable object with images or plots inserted.", + "text": "library(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\nx <- mtcars[1:4, 1:5]\n\n\n\nThe tt() function is minimalist; it’s inteded purpose is simply to draw nice tables. Users who want to format numbers, dates, strings, and other variables in different ways should process their data before supplying it to the tt() table-drawing function. To do so, we can use the format_tt() function supplied by the tinytable.\nIn a very simple case—such as printing 2 significant digits of all numeric variables—we can use the digits argument of tt():\n\ndat <- data.frame(\n w = c(143002.2092, 201399.181, 100188.3883),\n x = c(1.43402, 201.399, 0.134588),\n y = as.Date(sample(1:1000, 3), origin = \"1970-01-01\"),\n z = c(TRUE, TRUE, FALSE))\n\ntt(dat, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143002\n 1.43\n 1971-04-23\n True \n \n \n 201399\n 201.4 \n 1971-04-08\n True \n \n \n 100188\n 0.13\n 1970-02-22\n False\n \n \n \n \n\n\n\nWe can get more fine-grained control over formatting by calling format_tt() after tt(), optionally by specifying the columns to format with j:\n\ntt(dat) |> \n format_tt(\n j = 2:4,\n digits = 1,\n date = \"%B %d %Y\") |>\n format_tt(\n j = 1,\n digits = 2,\n num_mark_big = \" \",\n num_mark_dec = \",\",\n num_fmt = \"decimal\")\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143 002,21\n 1.4\n April 23 1971\n True\n \n \n 201 399,18\n 201.4\n April 08 1971\n True\n \n \n 100 188,39\n 0.1\n February 22 1970\n False\n \n \n \n \n\n\n\nWe can use a regular expression in j to select columns, and the ?sprintf function to format strings, numbers, and to do string interpolation (similar to the glue package, but using Base R):\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.432\n 99T\n \n \n Food: Halloumi\n 201.399\n 7.3B\n \n \n Food: Tofu\n 0.146\n 29M\n \n \n Food: Beans\n 0.003\n 94K\n \n \n \n \n\n\n\nFinally, if you like the format_tt() interface, you can use it directly with numbers, vectors, or data frames:\n\nformat_tt(pi, digits = 1)\n\n[1] \"3\"\n\nformat_tt(dat, digits = 1, num_suffix = TRUE)\n\n a b c\n1 Burger 1 99T\n2 Halloumi 201 7B\n3 Tofu 0.1 29M\n4 Beans 0.003 94K\n\n\n\n\n\nBy default, format_tt() formats numbers to ensure that the smallest value in a vector (column) has at least a certain number of significant digits. For example,\n\nk <- data.frame(x = c(0.000123456789, 12.4356789))\ntt(k, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12.43568\n \n \n \n \n\n\n\nWe can alter this behavior to ensure to round significant digits on a per-cell basis, using the num_fmt argument in format_tt():\n\ntt(k) |> format_tt(digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\n\nThe numeric formatting options in format_tt() can also be controlled using global options:\n\noptions(\"tinytable_tt_digits\" = 2)\noptions(\"tinytable_format_num_fmt\" = \"significant_cell\")\ntt(k)\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12 \n \n \n \n \n\n\n\n\n\n\nMissing values can be replaced by a custom string using the replace argument (default \"\"):\n\ntab <- data.frame(a = c(NA, 1, 2), b = c(3, NA, 5))\n\ntt(tab)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n NA\n 3\n \n \n 1\n NA\n \n \n 2\n 5\n \n \n \n \n\n\ntt(tab) |> format_tt()\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n \n 3\n \n \n 1\n \n \n \n 2\n 5\n \n \n \n \n\n\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\n\nWe can also specify multiple value replacements at once using a named list of vectors:\n\ntmp <- data.frame(x = 1:5, y = c(pi, NA, NaN, -Inf, Inf))\ndict <- list(\"-\" = c(NA, NaN), \"-∞\" = -Inf, \"∞\" = Inf)\ntt(tmp) |> format_tt(replace = dict, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n x\n y\n \n \n \n \n \n 1\n 3.1\n \n \n 2\n -\n \n \n 3\n -\n \n \n 4\n -∞\n \n \n 5\n ∞\n \n \n \n \n\n\n\n\n\n\nLaTeX and HTML use special characters to indicate strings which should be interpreted rather than displayed as text. For example, including underscores or dollar signs in LaTeX can cause compilation errors in some documents. To display those special characters, we need to substitute or escape them with backslashes, depending on the output format. The escape argument of format_tt() can be used to do this automatically:\n\ndat <- data.frame(\n \"LaTeX\" = c(\"Dollars $\", \"Percent %\", \"Underscore _\"),\n \"HTML\" = c(\"<br>\", \"<sup>4</sup>\", \"<emph>blah</emph>\")\n)\n\ntt(dat) |> format_tt(escape = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>\n \n \n \n \n\n\n\nWhen applied to a tt() table, format_tt() will determine the type of escaping to do automatically. When applied to a string or vector, we must specify the type of escaping to apply:\n\nformat_tt(\"_ Dollars $\", escape = \"latex\")\n\n[1] \"\\\\_ Dollars \\\\$\"\n\n\n\n\n\nMarkdown can be rendered in cells by using the markdown argument of the format_tt() function (note: this requires installing the markdown as an optional dependency).\n\ndat <- data.frame( markdown = c(\n \"This is _italic_ text.\",\n \"This sentence ends with a superscript.^2^\")\n)\n\ntt(dat) |>\n format_tt(j = 1, markdown = TRUE) |>\n style_tt(j = 1, align = \"c\")\n\n\n\n \n\n \n \n \n \n \n \n markdown\n \n \n \n \n \n This is italic text.\n \n \n This sentence ends with a superscript.2\n \n \n \n \n\n\n\nMarkdown syntax can be particularly useful when formatting URLs in a table:\n\ndat <- data.frame(\n `Package (link)` = c(\n \"[`marginaleffects`](https://www.marginaleffects.com/)\",\n \"[`modelsummary`](https://www.modelsummary.com/)\",\n \"[`tinytable`](https://vincentarelbundock.github.io/tinytable/)\",\n \"[`countrycode`](https://vincentarelbundock.github.io/countrycode/)\",\n \"[`WDI`](https://vincentarelbundock.github.io/WDI/)\",\n \"[`softbib`](https://vincentarelbundock.github.io/softbib/)\",\n \"[`tinysnapshot`](https://vincentarelbundock.github.io/tinysnapshot/)\",\n \"[`altdoc`](https://etiennebacher.github.io/altdoc/)\",\n \"[`tinyplot`](https://grantmcdermott.com/tinyplot/)\",\n \"[`parameters`](https://easystats.github.io/parameters/)\",\n \"[`insight`](https://easystats.github.io/insight/)\"\n ),\n Purpose = c(\n \"Interpreting statistical models\",\n \"Data and model summaries\",\n \"Draw beautiful tables easily\",\n \"Convert country codes and names\",\n \"Download data from the World Bank\",\n \"Software bibliographies in R\",\n \"Snapshots for unit tests using `tinytest`\",\n \"Create documentation website for R packages\",\n \"Extension of base R plot functions\",\n \"Extract from model objects\",\n \"Extract information from model objects\"\n ),\n check.names = FALSE\n)\n\ntt(dat) |> format_tt(j = 1, markdown = TRUE)\n\n\n\n \n\n \n \n Vincent sometimes contributes to these R packages.\n \n \n \n Package (link)\n Purpose\n \n \n \n \n \n marginaleffects\n Interpreting statistical models \n \n \n modelsummary\n Data and model summaries \n \n \n tinytable\n Draw beautiful tables easily \n \n \n countrycode\n Convert country codes and names \n \n \n WDI\n Download data from the World Bank \n \n \n softbib\n Software bibliographies in R \n \n \n tinysnapshot\n Snapshots for unit tests using `tinytest` \n \n \n altdoc\n Create documentation website for R packages\n \n \n tinyplot\n Extension of base R plot functions \n \n \n parameters\n Extract from model objects \n \n \n insight\n Extract information from model objects \n \n \n \n \n\n\n\n\n\n\nOn top of the built-in features of format_tt, a custom formatting function can be specified via the fn argument. The fn argument takes a function that accepts a single vector and returns a string (or something that coerces to a string like a number).\n\ntt(x) |> \n format_tt(j = \"mpg\", fn = function(x) paste0(x, \" mpg\")) |>\n format_tt(j = \"drat\", fn = \\(x) signif(x, 2))\n\n\n\n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21 mpg\n 6\n 160\n 110\n 3.9\n \n \n 21 mpg\n 6\n 160\n 110\n 3.9\n \n \n 22.8 mpg\n 4\n 108\n 93\n 3.8\n \n \n 21.4 mpg\n 6\n 258\n 110\n 3.1\n \n \n \n \n\n\n\nFor example, the scales package which is used internally by ggplot2 provides a bunch of useful tools for formatting (e.g. dates, numbers, percents, logs, currencies, etc.). The label_*() functions can be passed to the fn argument.\nNote that we call format_tt(escape = TRUE) at the end of the pipeline because the column names and cells include characters that need to be escaped in LaTeX: _, %, and $. This last call is superfluous in HTML.\n\nthumbdrives <- data.frame(\n date_lookup = as.Date(c(\"2024-01-15\", \"2024-01-18\", \"2024-01-14\", \"2024-01-16\")),\n price = c(18.49, 19.99, 24.99, 24.99),\n price_rank = c(1, 2, 3, 3),\n memory = c(16e9, 12e9, 10e9, 8e9),\n speed_benchmark = c(0.6, 0.73, 0.82, 0.99)\n)\n\ntt(thumbdrives) |>\n format_tt(j = 1, fn = scales::label_date(\"%e %b\", locale = \"fr\")) |>\n format_tt(j = 2, fn = scales::label_currency()) |>\n format_tt(j = 3, fn = scales::label_ordinal()) |> \n format_tt(j = 4, fn = scales::label_bytes()) |> \n format_tt(j = 5, fn = scales::label_percent()) |>\n format_tt(escape = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n date_lookup\n price\n price_rank\n memory\n speed_benchmark\n \n \n \n \n \n 2024-01-15\n $18.49\n 1st\n 16 GB\n 60%\n \n \n 2024-01-18\n $19.99\n 2nd\n 12 GB\n 73%\n \n \n 2024-01-14\n $24.99\n 3rd\n 10 GB\n 82%\n \n \n 2024-01-16\n $24.99\n 3rd\n 8 GB\n 99%\n \n \n \n \n\n\n\n\n\n\nQuarto automatically applies some data processing to the content of the tables it renders. By default, tinytable disables this processing, because it can enter in conflict with styling and formatting features of the package.\nTo enable Quarto data processing, we can use the quarto argument of the format_tt() function. This argument allows users to mark certain cells explicitly for processing by Quarto, by wrapping them in a special “span” called “data-qmd”, supported by Quarto:\n\nk <- data.frame(Thing = \"qwerty\", Citation = \"@Lovelace1842\")\n\ntt(k) |> format_tt(quarto = TRUE)\n\n\n\n \n\n \n \n \n\n\n\nThing\nCitation\n\n\n\n\nqwerty\nLovelace (1842)\n\n\n\n\n \n\n\n\nSome users may want to apply Quarto data processing to all tables. This can be done with themes:\n\ntheme_quarto <- function(x) format_tt(x, quarto = TRUE)\noptions(tinytable_tt_theme = theme_quarto)\n\ntt(k)\n\n\n\n \n\n \n \n \n\n\n\nThing\nCitation\n\n\n\n\nqwerty\nLovelace (1842)\n\n\n\n\n \n\n\n\nBack to normal:\n\noptions(tinytable_tt_theme = NULL)\n\nAlternatively, users can set a global option to process all tables in Quarto, but they will then have to mark each cell with special content using format_tt(quarto):\n\noptions(tinytable_quarto_disable_processing = FALSE)\n\ntt(x)\n\n\n\n \n\n \n \n \n\n\n\nmpg\ncyl\ndisp\nhp\ndrat\n\n\n\n\n21.0\n6\n160\n110\n3.90\n\n\n21.0\n6\n160\n110\n3.90\n\n\n22.8\n4\n108\n93\n3.85\n\n\n21.4\n6\n258\n110\n3.08\n\n\n\n\n \n\n\n\nNotice that Quarto is now processing the table, so we lose the default tinytable theme and get the default striped Quarto look.\nBack to normal:\n\noptions(tinytable_quarto_disable_processing = TRUE)", "crumbs": [ "Tutorial (PDF)", - "Functions", - "`plot_tt`" + "Tutorial", + "Format" ] }, { - "objectID": "man/plot_tt.html#insert-images-and-inline-plots-into-tinytable-objects", - "href": "man/plot_tt.html#insert-images-and-inline-plots-into-tinytable-objects", - "title": "tinytable", + "objectID": "vignettes/format.html#numbers-dates-strings-etc.", + "href": "vignettes/format.html#numbers-dates-strings-etc.", + "title": "Formatting", "section": "", - "text": "The plot_tt() function allows for the insertion of images and inline plots into tinytable objects. This function can handle both local and web-based images.\n\n\n\nplot_tt(\n x,\n i = NULL,\n j = NULL,\n fun = NULL,\n data = NULL,\n color = \"black\",\n xlim = NULL,\n height = 1,\n asp = 1/3,\n images = NULL,\n assets = \"tinytable_assets\",\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA tinytable object.\n\n\n\n\ni\n\n\nInteger vector, the row indices where images are to be inserted. If NULL, images will be inserted in all rows.\n\n\n\n\nj\n\n\nInteger vector, the column indices where images are to be inserted. If NULL, images will be inserted in all columns.\n\n\n\n\nfun\n\n\nString or function to generate inline plots.\n\n\nString: \"histogram\", \"density\", \"bar\", \"line\"\n\n\nFunctions that return ggplot2 objects.\n\n\nFunctions that return another function which generates a base R plot, ex: function(x) {function() hist(x)}\n\n\nSee the tutorial on the tinytable website for more information.\n\n\n\n\n\n\ndata\n\n\na list of data frames or vectors to be used by the plotting functions in fun.\n\n\n\n\ncolor\n\n\nstring Name of color to use for inline plots (passed to the col argument base graphics plots in R).\n\n\n\n\nxlim\n\n\nNumeric vector of length 2.\n\n\n\n\nheight\n\n\nNumeric, the height of the images in the table in em units.\n\n\n\n\nasp\n\n\nNumeric, aspect ratio of the plots (height / width).\n\n\n\n\nimages\n\n\nCharacter vector, the paths to the images to be inserted. Paths are relative to the main table file or Quarto (Rmarkdown) document.\n\n\n\n\nassets\n\n\nPath to the directory where generated assets are stored. This path is relative to the location where a table is saved.\n\n\n\n\n…\n\n\nExtra arguments are passed to the function in fun. Important: Custom plotting functions must always have … as an argument.\n\n\n\n\n\n\nThe plot_tt() can insert images and inline plots into tables.\n\n\n\nA modified tinytable object with images or plots inserted.", + "text": "The tt() function is minimalist; it’s inteded purpose is simply to draw nice tables. Users who want to format numbers, dates, strings, and other variables in different ways should process their data before supplying it to the tt() table-drawing function. To do so, we can use the format_tt() function supplied by the tinytable.\nIn a very simple case—such as printing 2 significant digits of all numeric variables—we can use the digits argument of tt():\n\ndat <- data.frame(\n w = c(143002.2092, 201399.181, 100188.3883),\n x = c(1.43402, 201.399, 0.134588),\n y = as.Date(sample(1:1000, 3), origin = \"1970-01-01\"),\n z = c(TRUE, TRUE, FALSE))\n\ntt(dat, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143002\n 1.43\n 1971-04-23\n True \n \n \n 201399\n 201.4 \n 1971-04-08\n True \n \n \n 100188\n 0.13\n 1970-02-22\n False\n \n \n \n \n\n\n\nWe can get more fine-grained control over formatting by calling format_tt() after tt(), optionally by specifying the columns to format with j:\n\ntt(dat) |> \n format_tt(\n j = 2:4,\n digits = 1,\n date = \"%B %d %Y\") |>\n format_tt(\n j = 1,\n digits = 2,\n num_mark_big = \" \",\n num_mark_dec = \",\",\n num_fmt = \"decimal\")\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143 002,21\n 1.4\n April 23 1971\n True\n \n \n 201 399,18\n 201.4\n April 08 1971\n True\n \n \n 100 188,39\n 0.1\n February 22 1970\n False\n \n \n \n \n\n\n\nWe can use a regular expression in j to select columns, and the ?sprintf function to format strings, numbers, and to do string interpolation (similar to the glue package, but using Base R):\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.432\n 99T\n \n \n Food: Halloumi\n 201.399\n 7.3B\n \n \n Food: Tofu\n 0.146\n 29M\n \n \n Food: Beans\n 0.003\n 94K\n \n \n \n \n\n\n\nFinally, if you like the format_tt() interface, you can use it directly with numbers, vectors, or data frames:\n\nformat_tt(pi, digits = 1)\n\n[1] \"3\"\n\nformat_tt(dat, digits = 1, num_suffix = TRUE)\n\n a b c\n1 Burger 1 99T\n2 Halloumi 201 7B\n3 Tofu 0.1 29M\n4 Beans 0.003 94K", "crumbs": [ "Tutorial (PDF)", - "Functions", - "`plot_tt`" + "Tutorial", + "Format" ] }, { - "objectID": "man/tt.html", - "href": "man/tt.html", - "title": "tinytable", + "objectID": "vignettes/format.html#significant-digits-and-decimals", + "href": "vignettes/format.html#significant-digits-and-decimals", + "title": "Formatting", "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\nEXPERIMENTAL options(tinytable_html_mathjax = TRUE) inserts MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\n\n\n\noptions(tinytable_save_pdf_clean = TRUE) deletes temporary and log files.\n\n\noptions(tinytable_save_pdf_engine = “xelatex”): \"xelatex\", \"pdflatex\", \"lualatex\"\n\n\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 \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\ntt(x,\n theme = \"striped\",\n width = 0.5,\n caption = \"Data about cars.\")\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\ntt(x, notes = \"Hello World!\")\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\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 \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12.43568", + "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 \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12.43568\n \n \n \n \n\n\n\nWe can alter this behavior to ensure to round significant digits on a per-cell basis, using the num_fmt argument in format_tt():\n\ntt(k) |> format_tt(digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\n\nThe numeric formatting options in format_tt() can also be controlled using global options:\n\noptions(\"tinytable_tt_digits\" = 2)\noptions(\"tinytable_format_num_fmt\" = \"significant_cell\")\ntt(k)\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12", "crumbs": [ "Tutorial (PDF)", - "Functions", - "`tt`" + "Tutorial", + "Format" ] }, { - "objectID": "man/tt.html#draw-a-tiny-table", - "href": "man/tt.html#draw-a-tiny-table", - "title": "tinytable", + "objectID": "vignettes/format.html#replacement", + "href": "vignettes/format.html#replacement", + "title": "Formatting", "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\nEXPERIMENTAL options(tinytable_html_mathjax = TRUE) inserts MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\n\n\n\noptions(tinytable_save_pdf_clean = TRUE) deletes temporary and log files.\n\n\noptions(tinytable_save_pdf_engine = “xelatex”): \"xelatex\", \"pdflatex\", \"lualatex\"\n\n\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 \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\ntt(x,\n theme = \"striped\",\n width = 0.5,\n caption = \"Data about cars.\")\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\ntt(x, notes = \"Hello World!\")\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\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 \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12.43568", + "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 \n \n \n \n \n a\n b\n \n \n \n \n \n NA\n 3\n \n \n 1\n NA\n \n \n 2\n 5\n \n \n \n \n\n\ntt(tab) |> format_tt()\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n \n 3\n \n \n 1\n \n \n \n 2\n 5\n \n \n \n \n\n\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\n\nWe can also specify multiple value replacements at once using a named list of vectors:\n\ntmp <- data.frame(x = 1:5, y = c(pi, NA, NaN, -Inf, Inf))\ndict <- list(\"-\" = c(NA, NaN), \"-∞\" = -Inf, \"∞\" = Inf)\ntt(tmp) |> format_tt(replace = dict, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n 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)", - "Functions", - "`tt`" + "Tutorial", + "Format" ] }, { - "objectID": "LICENSE.html", - "href": "LICENSE.html", - "title": "GNU General Public License", + "objectID": "vignettes/format.html#escape-special-characters", + "href": "vignettes/format.html#escape-special-characters", + "title": "Formatting", "section": "", - "text": "Version 3, 29 June 2007\nCopyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>\nEveryone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.\n\n\nThe GNU General Public License is a free, copyleft license for software and other kinds of works.\nThe licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program–to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.\nTo protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.\nFor example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.\nDevelopers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.\nFor the developers’ and authors’ protection, the GPL clearly explains that there is no warranty for this free software. For both users’ and authors’ sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.\nSome devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users’ freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.\nFinally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.\nThe precise terms and conditions for copying, distribution and modification follow.\n\n\n\n\n\n“This License” refers to version 3 of the GNU General Public License.\n“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.\n“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.\nTo “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.\nA “covered work” means either the unmodified Program or a work based on the Program.\nTo “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.\nTo “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.\nAn interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.\n\n\n\nThe “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.\nA “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.\nThe “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.\nThe “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work’s System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.\nThe Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.\nThe Corresponding Source for a work in source code form is that same work.\n\n\n\nAll rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.\nYou may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.\nConveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.\n\n\n\nNo covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.\nWhen you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work’s users, your or third parties’ legal rights to forbid circumvention of technological measures.\n\n\n\nYou may convey verbatim copies of the Program’s source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.\nYou may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.\n\n\n\nYou may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:\n\na) The work must carry prominent notices stating that you modified it, and giving a relevant date.\nb) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.\nc) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.\nd) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.\n\nA compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation’s users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.\n\n\n\nYou may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:\n\na) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.\nb) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.\nc) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.\nd) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.\ne) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.\n\nA separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.\nA “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.\n“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.\nIf you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).\nThe requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.\nCorresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.\n\n\n\n“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.\nWhen you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.\nNotwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:\n\na) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or\nb) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or\nc) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or\nd) Limiting the use for publicity purposes of names of licensors or authors of the material; or\ne) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or\nf) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.\n\nAll other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.\nIf you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.\nAdditional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.\n\n\n\nYou may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).\nHowever, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.\nMoreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.\nTermination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.\n\n\n\nYou are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.\n\n\n\nEach time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.\nAn “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party’s predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.\nYou may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.\n\n\n\nA “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor’s “contributor version”.\nA contributor’s “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.\nEach contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor’s essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.\nIn the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.\nIf you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient’s use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.\nIf, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.\nA patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.\nNothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.\n\n\n\nIf conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.\n\n\n\nNotwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.\n\n\n\nThe Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.\nEach version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.\nIf the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Program.\nLater license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.\n\n\n\nTHERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n\n\nIN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\n\n\n\nIf the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.\nEND OF TERMS AND CONDITIONS\n\n\n\n\nIf you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.\nTo do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.\n<one line to give the program's name and a brief idea of what it does.>\nCopyright (C) <year> <name of author>\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see <http://www.gnu.org/licenses/>.\nAlso add information on how to contact you by electronic and paper mail.\nIf the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:\n<program> Copyright (C) <year> <name of author>\nThis program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.\nThis is free software, and you are welcome to redistribute it\nunder certain conditions; type 'show c' for details.\nThe hypothetical commands show w and show c should show the appropriate parts of the General Public License. Of course, your program’s commands might be different; for a GUI interface, you would use an “about box”.\nYou should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.\nThe GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.", + "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 \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>\n \n \n \n \n\n\n\nWhen applied to a tt() table, format_tt() will determine the type of escaping to do automatically. When applied to a string or vector, we must specify the type of escaping to apply:\n\nformat_tt(\"_ Dollars $\", escape = \"latex\")\n\n[1] \"\\\\_ Dollars \\\\$\"", "crumbs": [ "Tutorial (PDF)", - "License" + "Tutorial", + "Format" ] }, { - "objectID": "LICENSE.html#preamble", - "href": "LICENSE.html#preamble", - "title": "GNU General Public License", - "section": "", - "text": "The GNU General Public License is a free, copyleft license for software and other kinds of works.\nThe licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program–to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.\nTo protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.\nFor example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.\nDevelopers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.\nFor the developers’ and authors’ protection, the GPL clearly explains that there is no warranty for this free software. For both users’ and authors’ sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.\nSome devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users’ freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.\nFinally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.\nThe precise terms and conditions for copying, distribution and modification follow.", - "crumbs": [ - "Tutorial (PDF)", - "License" - ] - }, - { - "objectID": "LICENSE.html#terms-and-conditions", - "href": "LICENSE.html#terms-and-conditions", - "title": "GNU General Public License", - "section": "", - "text": "“This License” refers to version 3 of the GNU General Public License.\n“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.\n“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.\nTo “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.\nA “covered work” means either the unmodified Program or a work based on the Program.\nTo “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.\nTo “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.\nAn interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.\n\n\n\nThe “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.\nA “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.\nThe “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.\nThe “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work’s System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.\nThe Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.\nThe Corresponding Source for a work in source code form is that same work.\n\n\n\nAll rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.\nYou may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.\nConveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.\n\n\n\nNo covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.\nWhen you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work’s users, your or third parties’ legal rights to forbid circumvention of technological measures.\n\n\n\nYou may convey verbatim copies of the Program’s source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.\nYou may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.\n\n\n\nYou may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:\n\na) The work must carry prominent notices stating that you modified it, and giving a relevant date.\nb) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.\nc) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.\nd) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.\n\nA compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation’s users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.\n\n\n\nYou may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:\n\na) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.\nb) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.\nc) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.\nd) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.\ne) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.\n\nA separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.\nA “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.\n“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.\nIf you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).\nThe requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.\nCorresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.\n\n\n\n“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.\nWhen you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.\nNotwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:\n\na) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or\nb) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or\nc) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or\nd) Limiting the use for publicity purposes of names of licensors or authors of the material; or\ne) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or\nf) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.\n\nAll other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.\nIf you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.\nAdditional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.\n\n\n\nYou may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).\nHowever, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.\nMoreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.\nTermination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.\n\n\n\nYou are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.\n\n\n\nEach time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.\nAn “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party’s predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.\nYou may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.\n\n\n\nA “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor’s “contributor version”.\nA contributor’s “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.\nEach contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor’s essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.\nIn the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.\nIf you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient’s use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.\nIf, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.\nA patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.\nNothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.\n\n\n\nIf conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.\n\n\n\nNotwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.\n\n\n\nThe Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.\nEach version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.\nIf the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Program.\nLater license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.\n\n\n\nTHERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n\n\nIN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\n\n\n\nIf the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.\nEND OF TERMS AND CONDITIONS", - "crumbs": [ - "Tutorial (PDF)", - "License" - ] - }, - { - "objectID": "LICENSE.html#how-to-apply-these-terms-to-your-new-programs", - "href": "LICENSE.html#how-to-apply-these-terms-to-your-new-programs", - "title": "GNU General Public License", - "section": "", - "text": "If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.\nTo do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.\n<one line to give the program's name and a brief idea of what it does.>\nCopyright (C) <year> <name of author>\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see <http://www.gnu.org/licenses/>.\nAlso add information on how to contact you by electronic and paper mail.\nIf the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:\n<program> Copyright (C) <year> <name of author>\nThis program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.\nThis is free software, and you are welcome to redistribute it\nunder certain conditions; type 'show c' for details.\nThe hypothetical commands show w and show c should show the appropriate parts of the General Public License. Of course, your program’s commands might be different; for a GUI interface, you would use an “about box”.\nYou should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.\nThe GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.", - "crumbs": [ - "Tutorial (PDF)", - "License" - ] - }, - { - "objectID": "CITATION.html", - "href": "CITATION.html", - "title": "Citation", - "section": "", - "text": "Citation\nTo cite package ‘tinytable’ in publications use:\n\nArel-Bundock V (????). tinytable: Simple and Configurable Tables in ‘HTML’, ‘LaTeX’, ‘Markdown’, ‘Word’, ‘PNG’, ‘PDF’, and ‘Typst’ Formats. R package version 0.3.0.32, https://vincentarelbundock.github.io/tinytable/.", - "crumbs": [ - "Tutorial (PDF)", - "Citation" - ] - }, - { - "objectID": "man/save_tt.html", - "href": "man/save_tt.html", - "title": "tinytable", - "section": "", - "text": "This function saves an object of class tinytable to a specified file and format, with an option to overwrite existing files.\n\n\n\nsave_tt(x, output, overwrite = FALSE)\n\n\n\n\n\n\n\nx\n\n\nThe tinytable object to be saved.\n\n\n\n\noutput\n\n\nString or file path.\n\n\nIf output is \"markdown\", \"latex\", \"html\", or \"typst\", the table is returned in a string as an R object.\n\n\nIf output is a valid file path, the table is saved to file. The supported extensions are: .docx, .html, .png, .pdf, .tex, .typ, and .md (with aliases .txt, .Rmd and .qmd).\n\n\n\n\n\n\noverwrite\n\n\nA logical value indicating whether to overwrite an existing file.\n\n\n\n\n\n\nA string or TRUE when the table is written to file.\n\n\n\n\nlibrary(\"tinytable\")\n\nlibrary(tinytable)\nx <- mtcars[1:4, 1:5]\n\nfn <- file.path(tempdir(), \"test.html\")\ntt(x) |> save_tt(fn, overwrite = TRUE)\n\nlibrary(tinytable)\nfilename <- file.path(tempdir(), \"table.tex\")\ntt(mtcars[1:4, 1:4]) |> save_tt(filename)", - "crumbs": [ - "Tutorial (PDF)", - "Functions", - "`save_tt`" - ] - }, - { - "objectID": "man/save_tt.html#save-a-tiny-table-to-file", - "href": "man/save_tt.html#save-a-tiny-table-to-file", - "title": "tinytable", - "section": "", - "text": "This function saves an object of class tinytable to a specified file and format, with an option to overwrite existing files.\n\n\n\nsave_tt(x, output, overwrite = FALSE)\n\n\n\n\n\n\n\nx\n\n\nThe tinytable object to be saved.\n\n\n\n\noutput\n\n\nString or file path.\n\n\nIf output is \"markdown\", \"latex\", \"html\", or \"typst\", the table is returned in a string as an R object.\n\n\nIf output is a valid file path, the table is saved to file. The supported extensions are: .docx, .html, .png, .pdf, .tex, .typ, and .md (with aliases .txt, .Rmd and .qmd).\n\n\n\n\n\n\noverwrite\n\n\nA logical value indicating whether to overwrite an existing file.\n\n\n\n\n\n\nA string or TRUE when the table is written to file.\n\n\n\n\nlibrary(\"tinytable\")\n\nlibrary(tinytable)\nx <- mtcars[1:4, 1:5]\n\nfn <- file.path(tempdir(), \"test.html\")\ntt(x) |> save_tt(fn, overwrite = TRUE)\n\nlibrary(tinytable)\nfilename <- file.path(tempdir(), \"table.tex\")\ntt(mtcars[1:4, 1:4]) |> save_tt(filename)", - "crumbs": [ - "Tutorial (PDF)", - "Functions", - "`save_tt`" - ] - }, - { - "objectID": "man/rbind2-tinytable-tinytable-method.html", - "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 \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\nrbind(x, y) |> format_tt(replace = \"\")\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# omit y header\nrbind2(x, y, headers = FALSE)\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# bind by position rather than column names\nrbind2(x, y, use_names = FALSE)\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", - "`rbind2`" - ] - }, - { - "objectID": "man/rbind2-tinytable-tinytable-method.html#combine-tinytable-objects-by-rows-vertically", - "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 \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\nrbind(x, y) |> format_tt(replace = \"\")\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# omit y header\nrbind2(x, y, headers = FALSE)\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# bind by position rather than column names\nrbind2(x, y, use_names = FALSE)\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", - "`rbind2`" - ] - }, - { - "objectID": "man/format_tt.html", - "href": "man/format_tt.html", - "title": "tinytable", + "objectID": "vignettes/format.html#markdown", + "href": "vignettes/format.html#markdown", + "title": "Formatting", "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\nEXPERIMENTAL options(tinytable_html_mathjax = TRUE) inserts MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\n\n\n\noptions(tinytable_save_pdf_clean = TRUE) deletes temporary and log files.\n\n\noptions(tinytable_save_pdf_engine = “xelatex”): \"xelatex\", \"pdflatex\", \"lualatex\"\n\n\n\n\n\n\nlibrary(\"tinytable\")\n\ndat <- data.frame(\n a = rnorm(3, mean = 10000),\n b = rnorm(3, 10000))\ntab <- tt(dat)\nformat_tt(tab,\n digits = 2,\n num_mark_dec = \",\",\n num_mark_big = \" \")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 10 000\n 10 001\n \n \n 9 999\n 9 998\n \n \n 9 997\n 10 000\n \n \n \n \n\n\nk <- tt(data.frame(x = c(0.000123456789, 12.4356789)))\nformat_tt(k, digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1, num_fmt = \"decimal\", num_zero = TRUE) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.4\n 99T\n \n \n Food: Halloumi\n 201.4\n 7.3B\n \n \n Food: Tofu\n 0.1\n 29M\n \n \n Food: Beans\n 0.0\n 94K\n \n \n \n \n\n\ny <- tt(data.frame(x = c(123456789.678, 12435.6789)))\nformat_tt(y, digits=3, num_mark_big=\" \")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 123 456 790\n \n \n 12 436\n \n \n \n \n\n\nx <- tt(data.frame(Text = c(\"_italicized text_\", \"__bold text__\")))\nformat_tt(x, markdown=TRUE)\n\n\n\n \n\n \n \n \n \n \n \n Text\n \n \n \n \n \n italicized text\n \n \n bold text\n \n \n \n \n\n\ntab <- data.frame(a = c(NA, 1, 2), b = c(3, NA, 5))\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\ndat <- data.frame(\n \"LaTeX\" = c(\"Dollars $\", \"Percent %\", \"Underscore _\"),\n \"HTML\" = c(\"<br>\", \"<sup>4</sup>\", \"<emph>blah</emph>\")\n)\ntt(dat) |> format_tt(escape = TRUE) \n\n\n\n \n\n \n \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>", + "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 \n \n \n \n \n markdown\n \n \n \n \n \n This is italic text.\n \n \n This sentence ends with a superscript.2\n \n \n \n \n\n\n\nMarkdown syntax can be particularly useful when formatting URLs in a table:\n\ndat <- data.frame(\n `Package (link)` = c(\n \"[`marginaleffects`](https://www.marginaleffects.com/)\",\n \"[`modelsummary`](https://www.modelsummary.com/)\",\n \"[`tinytable`](https://vincentarelbundock.github.io/tinytable/)\",\n \"[`countrycode`](https://vincentarelbundock.github.io/countrycode/)\",\n \"[`WDI`](https://vincentarelbundock.github.io/WDI/)\",\n \"[`softbib`](https://vincentarelbundock.github.io/softbib/)\",\n \"[`tinysnapshot`](https://vincentarelbundock.github.io/tinysnapshot/)\",\n \"[`altdoc`](https://etiennebacher.github.io/altdoc/)\",\n \"[`tinyplot`](https://grantmcdermott.com/tinyplot/)\",\n \"[`parameters`](https://easystats.github.io/parameters/)\",\n \"[`insight`](https://easystats.github.io/insight/)\"\n ),\n Purpose = c(\n \"Interpreting statistical models\",\n \"Data and model summaries\",\n \"Draw beautiful tables easily\",\n \"Convert country codes and names\",\n \"Download data from the World Bank\",\n \"Software bibliographies in R\",\n \"Snapshots for unit tests using `tinytest`\",\n \"Create documentation website for R packages\",\n \"Extension of base R plot functions\",\n \"Extract from model objects\",\n \"Extract information from model objects\"\n ),\n check.names = FALSE\n)\n\ntt(dat) |> format_tt(j = 1, markdown = TRUE)\n\n\n\n \n\n \n \n 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)", - "Functions", - "`format_tt`" + "Tutorial", + "Format" ] }, { - "objectID": "man/format_tt.html#format-columns-of-a-data-frame", - "href": "man/format_tt.html#format-columns-of-a-data-frame", - "title": "tinytable", + "objectID": "vignettes/format.html#custom-functions", + "href": "vignettes/format.html#custom-functions", + "title": "Formatting", "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\nEXPERIMENTAL options(tinytable_html_mathjax = TRUE) inserts MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\n\n\n\noptions(tinytable_save_pdf_clean = TRUE) deletes temporary and log files.\n\n\noptions(tinytable_save_pdf_engine = “xelatex”): \"xelatex\", \"pdflatex\", \"lualatex\"\n\n\n\n\n\n\nlibrary(\"tinytable\")\n\ndat <- data.frame(\n a = rnorm(3, mean = 10000),\n b = rnorm(3, 10000))\ntab <- tt(dat)\nformat_tt(tab,\n digits = 2,\n num_mark_dec = \",\",\n num_mark_big = \" \")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 10 000\n 10 001\n \n \n 9 999\n 9 998\n \n \n 9 997\n 10 000\n \n \n \n \n\n\nk <- tt(data.frame(x = c(0.000123456789, 12.4356789)))\nformat_tt(k, digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1, num_fmt = \"decimal\", num_zero = TRUE) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.4\n 99T\n \n \n Food: Halloumi\n 201.4\n 7.3B\n \n \n Food: Tofu\n 0.1\n 29M\n \n \n Food: Beans\n 0.0\n 94K\n \n \n \n \n\n\ny <- tt(data.frame(x = c(123456789.678, 12435.6789)))\nformat_tt(y, digits=3, num_mark_big=\" \")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 123 456 790\n \n \n 12 436\n \n \n \n \n\n\nx <- tt(data.frame(Text = c(\"_italicized text_\", \"__bold text__\")))\nformat_tt(x, markdown=TRUE)\n\n\n\n \n\n \n \n \n \n \n \n Text\n \n \n \n \n \n italicized text\n \n \n bold text\n \n \n \n \n\n\ntab <- data.frame(a = c(NA, 1, 2), b = c(3, NA, 5))\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\ndat <- data.frame(\n \"LaTeX\" = c(\"Dollars $\", \"Percent %\", \"Underscore _\"),\n \"HTML\" = c(\"<br>\", \"<sup>4</sup>\", \"<emph>blah</emph>\")\n)\ntt(dat) |> format_tt(escape = TRUE) \n\n\n\n \n\n \n \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>", + "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 \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21 mpg\n 6\n 160\n 110\n 3.9\n \n \n 21 mpg\n 6\n 160\n 110\n 3.9\n \n \n 22.8 mpg\n 4\n 108\n 93\n 3.8\n \n \n 21.4 mpg\n 6\n 258\n 110\n 3.1\n \n \n \n \n\n\n\nFor example, the scales package which is used internally by ggplot2 provides a bunch of useful tools for formatting (e.g. dates, numbers, percents, logs, currencies, etc.). The label_*() functions can be passed to the fn argument.\nNote that we call format_tt(escape = TRUE) at the end of the pipeline because the column names and cells include characters that need to be escaped in LaTeX: _, %, and $. This last call is superfluous in HTML.\n\nthumbdrives <- data.frame(\n date_lookup = as.Date(c(\"2024-01-15\", \"2024-01-18\", \"2024-01-14\", \"2024-01-16\")),\n price = c(18.49, 19.99, 24.99, 24.99),\n price_rank = c(1, 2, 3, 3),\n memory = c(16e9, 12e9, 10e9, 8e9),\n speed_benchmark = c(0.6, 0.73, 0.82, 0.99)\n)\n\ntt(thumbdrives) |>\n format_tt(j = 1, fn = scales::label_date(\"%e %b\", locale = \"fr\")) |>\n format_tt(j = 2, fn = scales::label_currency()) |>\n format_tt(j = 3, fn = scales::label_ordinal()) |> \n format_tt(j = 4, fn = scales::label_bytes()) |> \n format_tt(j = 5, fn = scales::label_percent()) |>\n format_tt(escape = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n 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)", - "Functions", - "`format_tt`" + "Tutorial", + "Format" ] }, { - "objectID": "man/group_tt.html", - "href": "man/group_tt.html", - "title": "tinytable", + "objectID": "vignettes/format.html#quarto-data-processing", + "href": "vignettes/format.html#quarto-data-processing", + "title": "Formatting", "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 \n \n \n\n \nFoo\nBar\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n \n \n 19.2\n 6\n 167.6\n 123\n 3.92\n \n \n \n \n\n\ndat <- mtcars[1:9, 1:8]\ntt(dat) |>\n group_tt(i = list(\n \"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7))\n\n\n\n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\ntt(dat) |>\n group_tt(\n j = list(\n \"Hamburgers\" = 1:3,\n \"Halloumi\" = 4:5,\n \"Tofu\" = 7))\n\n\n\n \n\n \n \n \n \n\nHamburgers\nHalloumi\n \nTofu\n \n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\nx <- mtcars[1:5, 1:6]\ntt(x) |>\n group_tt(j = list(\"Hello\" = 1:2, \"World\" = 3:4, \"Hello\" = 5:6)) |>\n group_tt(j = list(\"Foo\" = 1:3, \"Bar\" = 4:6))\n\n\n\n \n\n \n \n \n \n\nFoo\nBar\n\n\nHello\nWorld\nHello\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.620\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.875\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.320\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.215\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.440", + "text": "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 \n \n\n\n\nThing\nCitation\n\n\n\n\nqwerty\nLovelace (1842)\n\n\n\n\n \n\n\n\nSome users may want to apply Quarto data processing to all tables. This can be done with themes:\n\ntheme_quarto <- function(x) format_tt(x, quarto = TRUE)\noptions(tinytable_tt_theme = theme_quarto)\n\ntt(k)\n\n\n\n \n\n \n \n \n\n\n\nThing\nCitation\n\n\n\n\nqwerty\nLovelace (1842)\n\n\n\n\n \n\n\n\nBack to normal:\n\noptions(tinytable_tt_theme = NULL)\n\nAlternatively, users can set a global option to process all tables in Quarto, but they will then have to mark each cell with special content using format_tt(quarto):\n\noptions(tinytable_quarto_disable_processing = FALSE)\n\ntt(x)\n\n\n\n \n\n \n \n \n\n\n\nmpg\ncyl\ndisp\nhp\ndrat\n\n\n\n\n21.0\n6\n160\n110\n3.90\n\n\n21.0\n6\n160\n110\n3.90\n\n\n22.8\n4\n108\n93\n3.85\n\n\n21.4\n6\n258\n110\n3.08\n\n\n\n\n \n\n\n\nNotice that Quarto is now processing the table, so we lose the default tinytable theme and get the default striped Quarto look.\nBack to normal:\n\noptions(tinytable_quarto_disable_processing = TRUE)", "crumbs": [ "Tutorial (PDF)", - "Functions", - "`group_tt`" + "Tutorial", + "Format" ] }, { - "objectID": "man/group_tt.html#spanning-labels-to-identify-groups-of-rows-or-columns", - "href": "man/group_tt.html#spanning-labels-to-identify-groups-of-rows-or-columns", - "title": "tinytable", + "objectID": "vignettes/alternatives.html", + "href": "vignettes/alternatives.html", + "title": "Alternative packages", "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 \n \n \n\n \nFoo\nBar\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n \n \n 19.2\n 6\n 167.6\n 123\n 3.92\n \n \n \n \n\n\ndat <- mtcars[1:9, 1:8]\ntt(dat) |>\n group_tt(i = list(\n \"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7))\n\n\n\n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\ntt(dat) |>\n group_tt(\n j = list(\n \"Hamburgers\" = 1:3,\n \"Halloumi\" = 4:5,\n \"Tofu\" = 7))\n\n\n\n \n\n \n \n \n \n\nHamburgers\nHalloumi\n \nTofu\n \n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\nx <- mtcars[1:5, 1:6]\ntt(x) |>\n group_tt(j = list(\"Hello\" = 1:2, \"World\" = 3:4, \"Hello\" = 5:6)) |>\n group_tt(j = list(\"Foo\" = 1:3, \"Bar\" = 4:6))\n\n\n\n \n\n \n \n \n \n\nFoo\nBar\n\n\nHello\nWorld\nHello\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.620\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.875\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.320\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.215\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.440", + "text": "How does tinytable compare to alternative table-drawing packages in R? There are many fantastic table-drawing packages already out there; some with features that tinytable does not yet support. If you don’t find what you need in tinytable, I recommend you try one of these:\n\ngt\nkableExtra\nhuxtable\nDT\nflextable\n\nHere are a few totally biased (and possibly unfair) comments about each of them.\nThe first difference between tinytable and alternatives is that tinytable covers much of the same functionality without loading any other R package by default. I think it is very important for R package developers to have access to a table-drawing package that does not force them to import half of the tidyverse. In my view, this service to developers alone justifies writing a new package.\nNow let’s consider alternatives one by one.\ngt (62 dependencies) is an amazingly powerful table-drawing package; possibly the most powerful in R. I like it a lot, and it is the one I recommend if you don’t find the features you need in tinytable. The reasons I don’t personally use gt on a day-to-day basis are entirely subjective. First, and least important, I find its syntax very verbose: customizing any aspect of a table always seems to take many keystrokes. Second, and this is obviously a reflection of my own limitations, but I have never quite figured out how gt actually works; it has so many exported functions (180+!) that I get lost. gt is more powerful than tinytable, but that power comes at the price of complexity. One goal of tinytable is to let you do 98% of what you need by learning 4 simple functions; then you can use a bit of CSS or LaTeX if you need extreme customization.\nkableExtra (48 dependencies) is a very flexible package with amazing documentation. Before writing tinytable, I actually made a few very minor contributions and bug fixes to kableExtra. In the end, however, I concluded that while the package is great, its code base is too hard to maintain and extend. The challenge on the backend is that kableExtra accepts tables drawn as raw strings by the knitr package, and then modifies them using a series of complex regular expressions. The author has done truly amazing work, but it’s just a really difficult strategy to implement, scale, and maintain. (Incidentally, kableExtra is not very actively developed anymore.) Finally, I really like the concept of separating styling from data, and kableExtra modifies the content of every cell to style its content. That sometimes makes LaTeX and HTML code pretty hard to read and edit.\nhuxtable (28 dependencies) is an interesting and powerful-looking package, but I know it less well than the others. The key design decision of the author is that each feature is implemented with a distinct function. I understand that design impulse: going through the documentation of a function with 50 arguments can be daunting. That said, I feel that sifting through a manual with 300+ exported functions also makes for a steep learning curve. In addition, I prefer HTML and LaTeX code to be human-readable, in case I need to tweak them by hand before publication; huxtable tables are not that.\nDT (39 dependencies) is nice, but it only draws HTML table, so that’s a non-starter for me. I need HTML, LaTeX, Word, PNG, PDF, and Typst output, depending on the project I am working on.\nflextable (39 dependencies) is nice, but it does not support LaTeX, and I need that format for “real work.”\nAt this point, it’s useful to point out that there are also many packages to compute statistics and build tables (ex: modelsummary, gtsummary, table1). Many of those packages delegate the actual drawing of the tables (ie: lines and colors) to one of the table-drawing packages listed above. In that sense, tinytable should be seen as more of a complement than an alternative to data summary packages. The goal of tinytable is to help users and developers convert data frames into beautiful tables easily. What people put in those tables is outside the scope of tinytable. If you are interested in a package to create data summaries and regression tables/plots, please check out my modelsummary package: https://modelsummary.com\nDid I miss your favorite package? Drop me a note and I’ll add it to the list.", "crumbs": [ "Tutorial (PDF)", - "Functions", - "`group_tt`" + "Tutorial", + "Alternatives" ] }, { @@ -686,341 +595,453 @@ ] }, { - "objectID": "vignettes/alternatives.html", - "href": "vignettes/alternatives.html", - "title": "Alternative packages", + "objectID": "man/group_tt.html", + "href": "man/group_tt.html", + "title": "tinytable", "section": "", - "text": "How does tinytable compare to alternative table-drawing packages in R? There are many fantastic table-drawing packages already out there; some with features that tinytable does not yet support. If you don’t find what you need in tinytable, I recommend you try one of these:\n\ngt\nkableExtra\nhuxtable\nDT\nflextable\n\nHere are a few totally biased (and possibly unfair) comments about each of them.\nThe first difference between tinytable and alternatives is that tinytable covers much of the same functionality without loading any other R package by default. I think it is very important for R package developers to have access to a table-drawing package that does not force them to import half of the tidyverse. In my view, this service to developers alone justifies writing a new package.\nNow let’s consider alternatives one by one.\ngt (62 dependencies) is an amazingly powerful table-drawing package; possibly the most powerful in R. I like it a lot, and it is the one I recommend if you don’t find the features you need in tinytable. The reasons I don’t personally use gt on a day-to-day basis are entirely subjective. First, and least important, I find its syntax very verbose: customizing any aspect of a table always seems to take many keystrokes. Second, and this is obviously a reflection of my own limitations, but I have never quite figured out how gt actually works; it has so many exported functions (180+!) that I get lost. gt is more powerful than tinytable, but that power comes at the price of complexity. One goal of tinytable is to let you do 98% of what you need by learning 4 simple functions; then you can use a bit of CSS or LaTeX if you need extreme customization.\nkableExtra (48 dependencies) is a very flexible package with amazing documentation. Before writing tinytable, I actually made a few very minor contributions and bug fixes to kableExtra. In the end, however, I concluded that while the package is great, its code base is too hard to maintain and extend. The challenge on the backend is that kableExtra accepts tables drawn as raw strings by the knitr package, and then modifies them using a series of complex regular expressions. The author has done truly amazing work, but it’s just a really difficult strategy to implement, scale, and maintain. (Incidentally, kableExtra is not very actively developed anymore.) Finally, I really like the concept of separating styling from data, and kableExtra modifies the content of every cell to style its content. That sometimes makes LaTeX and HTML code pretty hard to read and edit.\nhuxtable (28 dependencies) is an interesting and powerful-looking package, but I know it less well than the others. The key design decision of the author is that each feature is implemented with a distinct function. I understand that design impulse: going through the documentation of a function with 50 arguments can be daunting. That said, I feel that sifting through a manual with 300+ exported functions also makes for a steep learning curve. In addition, I prefer HTML and LaTeX code to be human-readable, in case I need to tweak them by hand before publication; huxtable tables are not that.\nDT (39 dependencies) is nice, but it only draws HTML table, so that’s a non-starter for me. I need HTML, LaTeX, Word, PNG, PDF, and Typst output, depending on the project I am working on.\nflextable (39 dependencies) is nice, but it does not support LaTeX, and I need that format for “real work.”\nAt this point, it’s useful to point out that there are also many packages to compute statistics and build tables (ex: modelsummary, gtsummary, table1). Many of those packages delegate the actual drawing of the tables (ie: lines and colors) to one of the table-drawing packages listed above. In that sense, tinytable should be seen as more of a complement than an alternative to data summary packages. The goal of tinytable is to help users and developers convert data frames into beautiful tables easily. What people put in those tables is outside the scope of tinytable. If you are interested in a package to create data summaries and regression tables/plots, please check out my modelsummary package: https://modelsummary.com\nDid I miss your favorite package? Drop me a note and I’ll add it to the list.", + "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 \n \n \n\n \nFoo\nBar\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n \n \n 19.2\n 6\n 167.6\n 123\n 3.92\n \n \n \n \n\n\ndat <- mtcars[1:9, 1:8]\ntt(dat) |>\n group_tt(i = list(\n \"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7))\n\n\n\n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\ntt(dat) |>\n group_tt(\n j = list(\n \"Hamburgers\" = 1:3,\n \"Halloumi\" = 4:5,\n \"Tofu\" = 7))\n\n\n\n \n\n \n \n \n \n\nHamburgers\nHalloumi\n \nTofu\n \n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\nx <- mtcars[1:5, 1:6]\ntt(x) |>\n group_tt(j = list(\"Hello\" = 1:2, \"World\" = 3:4, \"Hello\" = 5:6)) |>\n group_tt(j = list(\"Foo\" = 1:3, \"Bar\" = 4:6))\n\n\n\n \n\n \n \n \n \n\nFoo\nBar\n\n\nHello\nWorld\nHello\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.620\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.875\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.320\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.215\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.440", "crumbs": [ "Tutorial (PDF)", - "Tutorial", - "Alternatives" + "Functions", + "`group_tt`" ] }, { - "objectID": "vignettes/format.html", - "href": "vignettes/format.html", - "title": "Formatting", + "objectID": "man/group_tt.html#spanning-labels-to-identify-groups-of-rows-or-columns", + "href": "man/group_tt.html#spanning-labels-to-identify-groups-of-rows-or-columns", + "title": "tinytable", "section": "", - "text": "library(tinytable)\noptions(tinytable_tt_digits = 3)\noptions(tinytable_theme_placement_latex_float = \"H\")\nx <- mtcars[1:4, 1:5]\n\n\n\nThe tt() function is minimalist; it’s inteded purpose is simply to draw nice tables. Users who want to format numbers, dates, strings, and other variables in different ways should process their data before supplying it to the tt() table-drawing function. To do so, we can use the format_tt() function supplied by the tinytable.\nIn a very simple case—such as printing 2 significant digits of all numeric variables—we can use the digits argument of tt():\n\ndat <- data.frame(\n w = c(143002.2092, 201399.181, 100188.3883),\n x = c(1.43402, 201.399, 0.134588),\n y = as.Date(sample(1:1000, 3), origin = \"1970-01-01\"),\n z = c(TRUE, TRUE, FALSE))\n\ntt(dat, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143002\n 1.43\n 1971-09-26\n True \n \n \n 201399\n 201.4 \n 1970-03-05\n True \n \n \n 100188\n 0.13\n 1970-05-01\n False\n \n \n \n \n\n\n\nWe can get more fine-grained control over formatting by calling format_tt() after tt(), optionally by specifying the columns to format with j:\n\ntt(dat) |> \n format_tt(\n j = 2:4,\n digits = 1,\n date = \"%B %d %Y\") |>\n format_tt(\n j = 1,\n digits = 2,\n num_mark_big = \" \",\n num_mark_dec = \",\",\n num_fmt = \"decimal\")\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143 002,21\n 1.4\n September 26 1971\n True\n \n \n 201 399,18\n 201.4\n March 05 1970\n True\n \n \n 100 188,39\n 0.1\n May 01 1970\n False\n \n \n \n \n\n\n\nWe can use a regular expression in j to select columns, and the ?sprintf function to format strings, numbers, and to do string interpolation (similar to the glue package, but using Base R):\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.432\n 99T\n \n \n Food: Halloumi\n 201.399\n 7.3B\n \n \n Food: Tofu\n 0.146\n 29M\n \n \n Food: Beans\n 0.003\n 94K\n \n \n \n \n\n\n\nFinally, if you like the format_tt() interface, you can use it directly with numbers, vectors, or data frames:\n\nformat_tt(pi, digits = 1)\n\n[1] \"3\"\n\nformat_tt(dat, digits = 1, num_suffix = TRUE)\n\n a b c\n1 Burger 1 99T\n2 Halloumi 201 7B\n3 Tofu 0.1 29M\n4 Beans 0.003 94K\n\n\n\n\n\nBy default, format_tt() formats numbers to ensure that the smallest value in a vector (column) has at least a certain number of significant digits. For example,\n\nk <- data.frame(x = c(0.000123456789, 12.4356789))\ntt(k, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12.43568\n \n \n \n \n\n\n\nWe can alter this behavior to ensure to round significant digits on a per-cell basis, using the num_fmt argument in format_tt():\n\ntt(k) |> format_tt(digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\n\nThe numeric formatting options in format_tt() can also be controlled using global options:\n\noptions(\"tinytable_tt_digits\" = 2)\noptions(\"tinytable_format_num_fmt\" = \"significant_cell\")\ntt(k)\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12 \n \n \n \n \n\n\n\n\n\n\nMissing values can be replaced by a custom string using the replace argument (default \"\"):\n\ntab <- data.frame(a = c(NA, 1, 2), b = c(3, NA, 5))\n\ntt(tab)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n NA\n 3\n \n \n 1\n NA\n \n \n 2\n 5\n \n \n \n \n\n\ntt(tab) |> format_tt()\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n \n 3\n \n \n 1\n \n \n \n 2\n 5\n \n \n \n \n\n\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\n\nWe can also specify multiple value replacements at once using a named list of vectors:\n\ntmp <- data.frame(x = 1:5, y = c(pi, NA, NaN, -Inf, Inf))\ndict <- list(\"-\" = c(NA, NaN), \"-∞\" = -Inf, \"∞\" = Inf)\ntt(tmp) |> format_tt(replace = dict, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n x\n y\n \n \n \n \n \n 1\n 3.1\n \n \n 2\n -\n \n \n 3\n -\n \n \n 4\n -∞\n \n \n 5\n ∞\n \n \n \n \n\n\n\n\n\n\nLaTeX and HTML use special characters to indicate strings which should be interpreted rather than displayed as text. For example, including underscores or dollar signs in LaTeX can cause compilation errors in some documents. To display those special characters, we need to substitute or escape them with backslashes, depending on the output format. The escape argument of format_tt() can be used to do this automatically:\n\ndat <- data.frame(\n \"LaTeX\" = c(\"Dollars $\", \"Percent %\", \"Underscore _\"),\n \"HTML\" = c(\"<br>\", \"<sup>4</sup>\", \"<emph>blah</emph>\")\n)\n\ntt(dat) |> format_tt(escape = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>\n \n \n \n \n\n\n\nWhen applied to a tt() table, format_tt() will determine the type of escaping to do automatically. When applied to a string or vector, we must specify the type of escaping to apply:\n\nformat_tt(\"_ Dollars $\", escape = \"latex\")\n\n[1] \"\\\\_ Dollars \\\\$\"\n\n\n\n\n\nMarkdown can be rendered in cells by using the markdown argument of the format_tt() function (note: this requires installing the markdown as an optional dependency).\n\ndat <- data.frame( markdown = c(\n \"This is _italic_ text.\",\n \"This sentence ends with a superscript.^2^\")\n)\n\ntt(dat) |>\n format_tt(j = 1, markdown = TRUE) |>\n style_tt(j = 1, align = \"c\")\n\n\n\n \n\n \n \n \n \n \n \n markdown\n \n \n \n \n \n This is italic text.\n \n \n This sentence ends with a superscript.2\n \n \n \n \n\n\n\nMarkdown syntax can be particularly useful when formatting URLs in a table:\n\ndat <- data.frame(\n `Package (link)` = c(\n \"[`marginaleffects`](https://www.marginaleffects.com/)\",\n \"[`modelsummary`](https://www.modelsummary.com/)\",\n \"[`tinytable`](https://vincentarelbundock.github.io/tinytable/)\",\n \"[`countrycode`](https://vincentarelbundock.github.io/countrycode/)\",\n \"[`WDI`](https://vincentarelbundock.github.io/WDI/)\",\n \"[`softbib`](https://vincentarelbundock.github.io/softbib/)\",\n \"[`tinysnapshot`](https://vincentarelbundock.github.io/tinysnapshot/)\",\n \"[`altdoc`](https://etiennebacher.github.io/altdoc/)\",\n \"[`tinyplot`](https://grantmcdermott.com/tinyplot/)\",\n \"[`parameters`](https://easystats.github.io/parameters/)\",\n \"[`insight`](https://easystats.github.io/insight/)\"\n ),\n Purpose = c(\n \"Interpreting statistical models\",\n \"Data and model summaries\",\n \"Draw beautiful tables easily\",\n \"Convert country codes and names\",\n \"Download data from the World Bank\",\n \"Software bibliographies in R\",\n \"Snapshots for unit tests using `tinytest`\",\n \"Create documentation website for R packages\",\n \"Extension of base R plot functions\",\n \"Extract from model objects\",\n \"Extract information from model objects\"\n ),\n check.names = FALSE\n)\n\ntt(dat) |> format_tt(j = 1, markdown = TRUE)\n\n\n\n \n\n \n \n Vincent sometimes contributes to these R packages.\n \n \n \n Package (link)\n Purpose\n \n \n \n \n \n marginaleffects\n Interpreting statistical models \n \n \n modelsummary\n Data and model summaries \n \n \n tinytable\n Draw beautiful tables easily \n \n \n countrycode\n Convert country codes and names \n \n \n WDI\n Download data from the World Bank \n \n \n softbib\n Software bibliographies in R \n \n \n tinysnapshot\n Snapshots for unit tests using `tinytest` \n \n \n altdoc\n Create documentation website for R packages\n \n \n tinyplot\n Extension of base R plot functions \n \n \n parameters\n Extract from model objects \n \n \n insight\n Extract information from model objects \n \n \n \n \n\n\n\n\n\n\nOn top of the built-in features of format_tt, a custom formatting function can be specified via the fn argument. The fn argument takes a function that accepts a single vector and returns a string (or something that coerces to a string like a number).\n\ntt(x) |> \n format_tt(j = \"mpg\", fn = function(x) paste0(x, \" mpg\")) |>\n format_tt(j = \"drat\", fn = \\(x) signif(x, 2))\n\n\n\n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21 mpg\n 6\n 160\n 110\n 3.9\n \n \n 21 mpg\n 6\n 160\n 110\n 3.9\n \n \n 22.8 mpg\n 4\n 108\n 93\n 3.8\n \n \n 21.4 mpg\n 6\n 258\n 110\n 3.1\n \n \n \n \n\n\n\nFor example, the scales package which is used internally by ggplot2 provides a bunch of useful tools for formatting (e.g. dates, numbers, percents, logs, currencies, etc.). The label_*() functions can be passed to the fn argument.\nNote that we call format_tt(escape = TRUE) at the end of the pipeline because the column names and cells include characters that need to be escaped in LaTeX: _, %, and $. This last call is superfluous in HTML.\n\nthumbdrives <- data.frame(\n date_lookup = as.Date(c(\"2024-01-15\", \"2024-01-18\", \"2024-01-14\", \"2024-01-16\")),\n price = c(18.49, 19.99, 24.99, 24.99),\n price_rank = c(1, 2, 3, 3),\n memory = c(16e9, 12e9, 10e9, 8e9),\n speed_benchmark = c(0.6, 0.73, 0.82, 0.99)\n)\n\ntt(thumbdrives) |>\n format_tt(j = 1, fn = scales::label_date(\"%e %b\", locale = \"fr\")) |>\n format_tt(j = 2, fn = scales::label_currency()) |>\n format_tt(j = 3, fn = scales::label_ordinal()) |> \n format_tt(j = 4, fn = scales::label_bytes()) |> \n format_tt(j = 5, fn = scales::label_percent()) |>\n format_tt(escape = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n date_lookup\n price\n price_rank\n memory\n speed_benchmark\n \n \n \n \n \n 2024-01-15\n $18.49\n 1st\n 16 GB\n 60%\n \n \n 2024-01-18\n $19.99\n 2nd\n 12 GB\n 73%\n \n \n 2024-01-14\n $24.99\n 3rd\n 10 GB\n 82%\n \n \n 2024-01-16\n $24.99\n 3rd\n 8 GB\n 99%\n \n \n \n \n\n\n\n\n\n\nQuarto automatically applies some data processing to the content of the tables it renders. By default, tinytable disables this processing, because it can enter in conflict with styling and formatting features of the package.\nTo enable Quarto data processing, we can use the quarto argument of the format_tt() function. This argument allows users to mark certain cells explicitly for processing by Quarto, by wrapping them in a special “span” called “data-qmd”, supported by Quarto:\n\nk <- data.frame(Thing = \"qwerty\", Citation = \"@Lovelace1842\")\n\ntt(k) |> format_tt(quarto = TRUE)\n\n\n\n \n\n \n \n \n\n\n\nThing\nCitation\n\n\n\n\nqwerty\nLovelace (1842)\n\n\n\n\n \n\n\n\nSome users may want to apply Quarto data processing to all tables. This can be done with themes:\n\ntheme_quarto <- function(x) format_tt(x, quarto = TRUE)\noptions(tinytable_tt_theme = theme_quarto)\n\ntt(k)\n\n\n\n \n\n \n \n \n\n\n\nThing\nCitation\n\n\n\n\nqwerty\nLovelace (1842)\n\n\n\n\n \n\n\n\nBack to normal:\n\noptions(tinytable_tt_theme = NULL)\n\nAlternatively, users can set a global option to process all tables in Quarto, but they will then have to mark each cell with special content using format_tt(quarto):\n\noptions(tinytable_quarto_disable_processing = FALSE)\n\ntt(x)\n\n\n\n \n\n \n \n \n\n\n\nmpg\ncyl\ndisp\nhp\ndrat\n\n\n\n\n21.0\n6\n160\n110\n3.90\n\n\n21.0\n6\n160\n110\n3.90\n\n\n22.8\n4\n108\n93\n3.85\n\n\n21.4\n6\n258\n110\n3.08\n\n\n\n\n \n\n\n\nNotice that Quarto is now processing the table, so we lose the default tinytable theme and get the default striped Quarto look.\nBack to normal:\n\noptions(tinytable_quarto_disable_processing = TRUE)", + "text": "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 \n \n \n\n \nFoo\nBar\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n \n \n 19.2\n 6\n 167.6\n 123\n 3.92\n \n \n \n \n\n\ndat <- mtcars[1:9, 1:8]\ntt(dat) |>\n group_tt(i = list(\n \"I like (fake) hamburgers\" = 3,\n \"She prefers halloumi\" = 4,\n \"They love tofu\" = 7))\n\n\n\n \n\n \n \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\ntt(dat) |>\n group_tt(\n j = list(\n \"Hamburgers\" = 1:3,\n \"Halloumi\" = 4:5,\n \"Tofu\" = 7))\n\n\n\n \n\n \n \n \n \n\nHamburgers\nHalloumi\n \nTofu\n \n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n qsec\n vs\n \n \n \n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.620\n 16.46\n 0\n \n \n 21.0\n 6\n 160.0\n 110\n 3.90\n 2.875\n 17.02\n 0\n \n \n 22.8\n 4\n 108.0\n 93\n 3.85\n 2.320\n 18.61\n 1\n \n \n 21.4\n 6\n 258.0\n 110\n 3.08\n 3.215\n 19.44\n 1\n \n \n 18.7\n 8\n 360.0\n 175\n 3.15\n 3.440\n 17.02\n 0\n \n \n 18.1\n 6\n 225.0\n 105\n 2.76\n 3.460\n 20.22\n 1\n \n \n 14.3\n 8\n 360.0\n 245\n 3.21\n 3.570\n 15.84\n 0\n \n \n 24.4\n 4\n 146.7\n 62\n 3.69\n 3.190\n 20.00\n 1\n \n \n 22.8\n 4\n 140.8\n 95\n 3.92\n 3.150\n 22.90\n 1\n \n \n \n \n\n\nx <- mtcars[1:5, 1:6]\ntt(x) |>\n group_tt(j = list(\"Hello\" = 1:2, \"World\" = 3:4, \"Hello\" = 5:6)) |>\n group_tt(j = list(\"Foo\" = 1:3, \"Bar\" = 4:6))\n\n\n\n \n\n \n \n \n \n\nFoo\nBar\n\n\nHello\nWorld\nHello\n\n \n \n mpg\n cyl\n disp\n hp\n drat\n wt\n \n \n \n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.620\n \n \n 21.0\n 6\n 160\n 110\n 3.90\n 2.875\n \n \n 22.8\n 4\n 108\n 93\n 3.85\n 2.320\n \n \n 21.4\n 6\n 258\n 110\n 3.08\n 3.215\n \n \n 18.7\n 8\n 360\n 175\n 3.15\n 3.440", "crumbs": [ "Tutorial (PDF)", - "Tutorial", - "Format" + "Functions", + "`group_tt`" ] }, { - "objectID": "vignettes/format.html#numbers-dates-strings-etc.", - "href": "vignettes/format.html#numbers-dates-strings-etc.", - "title": "Formatting", + "objectID": "man/format_tt.html", + "href": "man/format_tt.html", + "title": "tinytable", "section": "", - "text": "The tt() function is minimalist; it’s inteded purpose is simply to draw nice tables. Users who want to format numbers, dates, strings, and other variables in different ways should process their data before supplying it to the tt() table-drawing function. To do so, we can use the format_tt() function supplied by the tinytable.\nIn a very simple case—such as printing 2 significant digits of all numeric variables—we can use the digits argument of tt():\n\ndat <- data.frame(\n w = c(143002.2092, 201399.181, 100188.3883),\n x = c(1.43402, 201.399, 0.134588),\n y = as.Date(sample(1:1000, 3), origin = \"1970-01-01\"),\n z = c(TRUE, TRUE, FALSE))\n\ntt(dat, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143002\n 1.43\n 1971-09-26\n True \n \n \n 201399\n 201.4 \n 1970-03-05\n True \n \n \n 100188\n 0.13\n 1970-05-01\n False\n \n \n \n \n\n\n\nWe can get more fine-grained control over formatting by calling format_tt() after tt(), optionally by specifying the columns to format with j:\n\ntt(dat) |> \n format_tt(\n j = 2:4,\n digits = 1,\n date = \"%B %d %Y\") |>\n format_tt(\n j = 1,\n digits = 2,\n num_mark_big = \" \",\n num_mark_dec = \",\",\n num_fmt = \"decimal\")\n\n\n\n \n\n \n \n \n \n \n \n w\n x\n y\n z\n \n \n \n \n \n 143 002,21\n 1.4\n September 26 1971\n True\n \n \n 201 399,18\n 201.4\n March 05 1970\n True\n \n \n 100 188,39\n 0.1\n May 01 1970\n False\n \n \n \n \n\n\n\nWe can use a regular expression in j to select columns, and the ?sprintf function to format strings, numbers, and to do string interpolation (similar to the glue package, but using Base R):\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.432\n 99T\n \n \n Food: Halloumi\n 201.399\n 7.3B\n \n \n Food: Tofu\n 0.146\n 29M\n \n \n Food: Beans\n 0.003\n 94K\n \n \n \n \n\n\n\nFinally, if you like the format_tt() interface, you can use it directly with numbers, vectors, or data frames:\n\nformat_tt(pi, digits = 1)\n\n[1] \"3\"\n\nformat_tt(dat, digits = 1, num_suffix = TRUE)\n\n a b c\n1 Burger 1 99T\n2 Halloumi 201 7B\n3 Tofu 0.1 29M\n4 Beans 0.003 94K", + "text": "This function formats the columns of a data frame based on the column type (logical, date, numeric). It allows various formatting options like significant digits, decimal points, and scientific notation. It also includes custom formatting for date and boolean values. If this function is applied several times to the same cell, the last transformation is retained and the previous calls are ignored, except for the escape argument which can be applied to previously transformed data.\n\n\n\nformat_tt(\n x,\n i = NULL,\n j = NULL,\n digits = get_option(\"tinytable_format_digits\", default = NULL),\n num_fmt = get_option(\"tinytable_format_num_fmt\", default = \"significant\"),\n num_zero = get_option(\"tinytable_format_num_zero\", default = FALSE),\n num_suffix = get_option(\"tinytable_format_num_suffix\", default = FALSE),\n num_mark_big = get_option(\"tinytable_format_num_mark_big\", default = \"\"),\n num_mark_dec = get_option(\"tinytable_format_num_mark_dec\", default =\n getOption(\"OutDec\", default = \".\")),\n date = get_option(\"tinytable_format_date\", default = \"%Y-%m-%d\"),\n bool = get_option(\"tinytable_format_bool\", default = function(column)\n tools::toTitleCase(tolower(column))),\n other = get_option(\"tinytable_format_other\", default = as.character),\n replace = get_option(\"tinytable_format_replace\", default = TRUE),\n escape = get_option(\"tinytable_format_escape\", default = FALSE),\n markdown = get_option(\"tinytable_format_markdown\", default = FALSE),\n quarto = get_option(\"tinytable_format_quarto\", default = FALSE),\n fn = get_option(\"tinytable_format_fn\", default = NULL),\n sprintf = get_option(\"tinytable_format_sprintf\", default = NULL),\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA data frame or a vector to be formatted.\n\n\n\n\ni\n\n\nRow indices where the formatting should be applied.\n\n\n\n\nj\n\n\nColumn indices where the styling should be applied. Can be:\n\n\nInteger vectors indicating column positions.\n\n\nCharacter vector indicating column names.\n\n\nA single string specifying a Perl-style regular expression used to match column names.\n\n\n\n\n\n\ndigits\n\n\nNumber of significant digits or decimal places.\n\n\n\n\nnum_fmt\n\n\nThe format for numeric values; one of ‘significant’, ‘significant_cell’, ‘decimal’, or ‘scientific’.\n\n\n\n\nnum_zero\n\n\nLogical; if TRUE, trailing zeros are kept in \"decimal\" format (but not in \"significant\" format).\n\n\n\n\nnum_suffix\n\n\nLogical; if TRUE display short numbers with digits significant digits and K (thousands), M (millions), B (billions), or T (trillions) suffixes.\n\n\n\n\nnum_mark_big\n\n\nCharacter to use as a thousands separator.\n\n\n\n\nnum_mark_dec\n\n\nDecimal mark character. Default is the global option ‘OutDec’.\n\n\n\n\ndate\n\n\nA string passed to the format() function, such as \"%Y-%m-%d\". See the \"Details\" section in ?strptime\n\n\n\n\nbool\n\n\nA function to format logical columns. Defaults to title case.\n\n\n\n\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\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\nEXPERIMENTAL options(tinytable_html_mathjax = TRUE) inserts MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\n\n\n\noptions(tinytable_pdf_clean = TRUE) deletes temporary and log files.\n\n\noptions(tinytable_pdf_engine = “xelatex”): \"xelatex\", \"pdflatex\", \"lualatex\"\n\n\n\n\n\noptions(tinytable_markdown_hlines = TRUE) sets whether gridlines are included in markdown tables. This should be true for docx conversion.\n\n\n\n\n\n\nlibrary(\"tinytable\")\n\ndat <- data.frame(\n a = rnorm(3, mean = 10000),\n b = rnorm(3, 10000))\ntab <- tt(dat)\nformat_tt(tab,\n digits = 2,\n num_mark_dec = \",\",\n num_mark_big = \" \")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 10 001\n 10 000\n \n \n 10 000\n 10 000\n \n \n 10 000\n 10 000\n \n \n \n \n\n\nk <- tt(data.frame(x = c(0.000123456789, 12.4356789)))\nformat_tt(k, digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1, num_fmt = \"decimal\", num_zero = TRUE) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.4\n 99T\n \n \n Food: Halloumi\n 201.4\n 7.3B\n \n \n Food: Tofu\n 0.1\n 29M\n \n \n Food: Beans\n 0.0\n 94K\n \n \n \n \n\n\ny <- tt(data.frame(x = c(123456789.678, 12435.6789)))\nformat_tt(y, digits=3, num_mark_big=\" \")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 123 456 790\n \n \n 12 436\n \n \n \n \n\n\nx <- tt(data.frame(Text = c(\"_italicized text_\", \"__bold text__\")))\nformat_tt(x, markdown=TRUE)\n\n\n\n \n\n \n \n \n \n \n \n Text\n \n \n \n \n \n italicized text\n \n \n bold text\n \n \n \n \n\n\ntab <- data.frame(a = c(NA, 1, 2), b = c(3, NA, 5))\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\ndat <- data.frame(\n \"LaTeX\" = c(\"Dollars $\", \"Percent %\", \"Underscore _\"),\n \"HTML\" = c(\"<br>\", \"<sup>4</sup>\", \"<emph>blah</emph>\")\n)\ntt(dat) |> format_tt(escape = TRUE) \n\n\n\n \n\n \n \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>", "crumbs": [ "Tutorial (PDF)", - "Tutorial", - "Format" + "Functions", + "`format_tt`" ] }, { - "objectID": "vignettes/format.html#significant-digits-and-decimals", - "href": "vignettes/format.html#significant-digits-and-decimals", - "title": "Formatting", + "objectID": "man/format_tt.html#format-columns-of-a-data-frame", + "href": "man/format_tt.html#format-columns-of-a-data-frame", + "title": "tinytable", "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 \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12.43568\n \n \n \n \n\n\n\nWe can alter this behavior to ensure to round significant digits on a per-cell basis, using the num_fmt argument in format_tt():\n\ntt(k) |> format_tt(digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\n\nThe numeric formatting options in format_tt() can also be controlled using global options:\n\noptions(\"tinytable_tt_digits\" = 2)\noptions(\"tinytable_format_num_fmt\" = \"significant_cell\")\ntt(k)\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12", + "text": "This function formats the columns of a data frame based on the column type (logical, date, numeric). It allows various formatting options like significant digits, decimal points, and scientific notation. It also includes custom formatting for date and boolean values. If this function is applied several times to the same cell, the last transformation is retained and the previous calls are ignored, except for the escape argument which can be applied to previously transformed data.\n\n\n\nformat_tt(\n x,\n i = NULL,\n j = NULL,\n digits = get_option(\"tinytable_format_digits\", default = NULL),\n num_fmt = get_option(\"tinytable_format_num_fmt\", default = \"significant\"),\n num_zero = get_option(\"tinytable_format_num_zero\", default = FALSE),\n num_suffix = get_option(\"tinytable_format_num_suffix\", default = FALSE),\n num_mark_big = get_option(\"tinytable_format_num_mark_big\", default = \"\"),\n num_mark_dec = get_option(\"tinytable_format_num_mark_dec\", default =\n getOption(\"OutDec\", default = \".\")),\n date = get_option(\"tinytable_format_date\", default = \"%Y-%m-%d\"),\n bool = get_option(\"tinytable_format_bool\", default = function(column)\n tools::toTitleCase(tolower(column))),\n other = get_option(\"tinytable_format_other\", default = as.character),\n replace = get_option(\"tinytable_format_replace\", default = TRUE),\n escape = get_option(\"tinytable_format_escape\", default = FALSE),\n markdown = get_option(\"tinytable_format_markdown\", default = FALSE),\n quarto = get_option(\"tinytable_format_quarto\", default = FALSE),\n fn = get_option(\"tinytable_format_fn\", default = NULL),\n sprintf = get_option(\"tinytable_format_sprintf\", default = NULL),\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA data frame or a vector to be formatted.\n\n\n\n\ni\n\n\nRow indices where the formatting should be applied.\n\n\n\n\nj\n\n\nColumn indices where the styling should be applied. Can be:\n\n\nInteger vectors indicating column positions.\n\n\nCharacter vector indicating column names.\n\n\nA single string specifying a Perl-style regular expression used to match column names.\n\n\n\n\n\n\ndigits\n\n\nNumber of significant digits or decimal places.\n\n\n\n\nnum_fmt\n\n\nThe format for numeric values; one of ‘significant’, ‘significant_cell’, ‘decimal’, or ‘scientific’.\n\n\n\n\nnum_zero\n\n\nLogical; if TRUE, trailing zeros are kept in \"decimal\" format (but not in \"significant\" format).\n\n\n\n\nnum_suffix\n\n\nLogical; if TRUE display short numbers with digits significant digits and K (thousands), M (millions), B (billions), or T (trillions) suffixes.\n\n\n\n\nnum_mark_big\n\n\nCharacter to use as a thousands separator.\n\n\n\n\nnum_mark_dec\n\n\nDecimal mark character. Default is the global option ‘OutDec’.\n\n\n\n\ndate\n\n\nA string passed to the format() function, such as \"%Y-%m-%d\". See the \"Details\" section in ?strptime\n\n\n\n\nbool\n\n\nA function to format logical columns. Defaults to title case.\n\n\n\n\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\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\nEXPERIMENTAL options(tinytable_html_mathjax = TRUE) inserts MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\n\n\n\noptions(tinytable_pdf_clean = TRUE) deletes temporary and log files.\n\n\noptions(tinytable_pdf_engine = “xelatex”): \"xelatex\", \"pdflatex\", \"lualatex\"\n\n\n\n\n\noptions(tinytable_markdown_hlines = TRUE) sets whether gridlines are included in markdown tables. This should be true for docx conversion.\n\n\n\n\n\n\nlibrary(\"tinytable\")\n\ndat <- data.frame(\n a = rnorm(3, mean = 10000),\n b = rnorm(3, 10000))\ntab <- tt(dat)\nformat_tt(tab,\n digits = 2,\n num_mark_dec = \",\",\n num_mark_big = \" \")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n 10 001\n 10 000\n \n \n 10 000\n 10 000\n \n \n 10 000\n 10 000\n \n \n \n \n\n\nk <- tt(data.frame(x = c(0.000123456789, 12.4356789)))\nformat_tt(k, digits = 2, num_fmt = \"significant_cell\")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12\n \n \n \n \n\n\ndat <- data.frame(\n a = c(\"Burger\", \"Halloumi\", \"Tofu\", \"Beans\"),\n b = c(1.43202, 201.399, 0.146188, 0.0031),\n c = c(98938272783457, 7288839482, 29111727, 93945))\ntt(dat) |>\n format_tt(j = \"a\", sprintf = \"Food: %s\") |>\n format_tt(j = 2, digits = 1, num_fmt = \"decimal\", num_zero = TRUE) |>\n format_tt(j = \"c\", digits = 2, num_suffix = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n c\n \n \n \n \n \n Food: Burger\n 1.4\n 99T\n \n \n Food: Halloumi\n 201.4\n 7.3B\n \n \n Food: Tofu\n 0.1\n 29M\n \n \n Food: Beans\n 0.0\n 94K\n \n \n \n \n\n\ny <- tt(data.frame(x = c(123456789.678, 12435.6789)))\nformat_tt(y, digits=3, num_mark_big=\" \")\n\n\n\n \n\n \n \n \n \n \n \n x\n \n \n \n \n \n 123 456 790\n \n \n 12 436\n \n \n \n \n\n\nx <- tt(data.frame(Text = c(\"_italicized text_\", \"__bold text__\")))\nformat_tt(x, markdown=TRUE)\n\n\n\n \n\n \n \n \n \n \n \n Text\n \n \n \n \n \n italicized text\n \n \n bold text\n \n \n \n \n\n\ntab <- data.frame(a = c(NA, 1, 2), b = c(3, NA, 5))\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\ndat <- data.frame(\n \"LaTeX\" = c(\"Dollars $\", \"Percent %\", \"Underscore _\"),\n \"HTML\" = c(\"<br>\", \"<sup>4</sup>\", \"<emph>blah</emph>\")\n)\ntt(dat) |> format_tt(escape = TRUE) \n\n\n\n \n\n \n \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>", "crumbs": [ "Tutorial (PDF)", - "Tutorial", - "Format" + "Functions", + "`format_tt`" ] }, { - "objectID": "vignettes/format.html#replacement", - "href": "vignettes/format.html#replacement", - "title": "Formatting", + "objectID": "man/rbind2-tinytable-tinytable-method.html", + "href": "man/rbind2-tinytable-tinytable-method.html", + "title": "tinytable", "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 \n \n \n \n \n a\n b\n \n \n \n \n \n NA\n 3\n \n \n 1\n NA\n \n \n 2\n 5\n \n \n \n \n\n\ntt(tab) |> format_tt()\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n \n 3\n \n \n 1\n \n \n \n 2\n 5\n \n \n \n \n\n\ntt(tab) |> format_tt(replace = \"-\")\n\n\n\n \n\n \n \n \n \n \n \n a\n b\n \n \n \n \n \n -\n 3\n \n \n 1\n -\n \n \n 2\n 5\n \n \n \n \n\n\n\nWe can also specify multiple value replacements at once using a named list of vectors:\n\ntmp <- data.frame(x = 1:5, y = c(pi, NA, NaN, -Inf, Inf))\ndict <- list(\"-\" = c(NA, NaN), \"-∞\" = -Inf, \"∞\" = Inf)\ntt(tmp) |> format_tt(replace = dict, digits = 2)\n\n\n\n \n\n \n \n \n \n \n \n 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": "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 \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\nrbind(x, y) |> format_tt(replace = \"\")\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# omit y header\nrbind2(x, y, headers = FALSE)\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# bind by position rather than column names\nrbind2(x, y, use_names = FALSE)\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)", - "Tutorial", - "Format" + "Functions", + "`rbind2`" ] }, { - "objectID": "vignettes/format.html#escape-special-characters", - "href": "vignettes/format.html#escape-special-characters", - "title": "Formatting", + "objectID": "man/rbind2-tinytable-tinytable-method.html#combine-tinytable-objects-by-rows-vertically", + "href": "man/rbind2-tinytable-tinytable-method.html#combine-tinytable-objects-by-rows-vertically", + "title": "tinytable", "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 \n \n \n \n \n LaTeX\n HTML\n \n \n \n \n \n Dollars $\n <br>\n \n \n Percent %\n <sup>4</sup>\n \n \n Underscore _\n <emph>blah</emph>\n \n \n \n \n\n\n\nWhen applied to a tt() table, format_tt() will determine the type of escaping to do automatically. When applied to a string or vector, we must specify the type of escaping to apply:\n\nformat_tt(\"_ Dollars $\", escape = \"latex\")\n\n[1] \"\\\\_ Dollars \\\\$\"", + "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 \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\nrbind(x, y) |> format_tt(replace = \"\")\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# omit y header\nrbind2(x, y, headers = FALSE)\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# bind by position rather than column names\nrbind2(x, y, use_names = FALSE)\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)", - "Tutorial", - "Format" + "Functions", + "`rbind2`" ] }, { - "objectID": "vignettes/format.html#markdown", - "href": "vignettes/format.html#markdown", - "title": "Formatting", + "objectID": "man/save_tt.html", + "href": "man/save_tt.html", + "title": "tinytable", "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 \n \n \n \n \n markdown\n \n \n \n \n \n This is italic text.\n \n \n This sentence ends with a superscript.2\n \n \n \n \n\n\n\nMarkdown syntax can be particularly useful when formatting URLs in a table:\n\ndat <- data.frame(\n `Package (link)` = c(\n \"[`marginaleffects`](https://www.marginaleffects.com/)\",\n \"[`modelsummary`](https://www.modelsummary.com/)\",\n \"[`tinytable`](https://vincentarelbundock.github.io/tinytable/)\",\n \"[`countrycode`](https://vincentarelbundock.github.io/countrycode/)\",\n \"[`WDI`](https://vincentarelbundock.github.io/WDI/)\",\n \"[`softbib`](https://vincentarelbundock.github.io/softbib/)\",\n \"[`tinysnapshot`](https://vincentarelbundock.github.io/tinysnapshot/)\",\n \"[`altdoc`](https://etiennebacher.github.io/altdoc/)\",\n \"[`tinyplot`](https://grantmcdermott.com/tinyplot/)\",\n \"[`parameters`](https://easystats.github.io/parameters/)\",\n \"[`insight`](https://easystats.github.io/insight/)\"\n ),\n Purpose = c(\n \"Interpreting statistical models\",\n \"Data and model summaries\",\n \"Draw beautiful tables easily\",\n \"Convert country codes and names\",\n \"Download data from the World Bank\",\n \"Software bibliographies in R\",\n \"Snapshots for unit tests using `tinytest`\",\n \"Create documentation website for R packages\",\n \"Extension of base R plot functions\",\n \"Extract from model objects\",\n \"Extract information from model objects\"\n ),\n check.names = FALSE\n)\n\ntt(dat) |> format_tt(j = 1, markdown = TRUE)\n\n\n\n \n\n \n \n 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": "This function saves an object of class tinytable to a specified file and format, with an option to overwrite existing files.\n\n\n\nsave_tt(x, output, overwrite = FALSE)\n\n\n\n\n\n\n\nx\n\n\nThe tinytable object to be saved.\n\n\n\n\noutput\n\n\nString or file path.\n\n\nIf output is \"markdown\", \"latex\", \"html\", or \"typst\", the table is returned in a string as an R object.\n\n\nIf output is a valid file path, the table is saved to file. The supported extensions are: .docx, .html, .png, .pdf, .tex, .typ, and .md (with aliases .txt, .Rmd and .qmd).\n\n\n\n\n\n\noverwrite\n\n\nA logical value indicating whether to overwrite an existing file.\n\n\n\n\n\n\nA string or TRUE when the table is written to file.\n\n\n\n\nlibrary(\"tinytable\")\n\nlibrary(tinytable)\nx <- mtcars[1:4, 1:5]\n\nfn <- file.path(tempdir(), \"test.html\")\ntt(x) |> save_tt(fn, overwrite = TRUE)\n\nlibrary(tinytable)\nfilename <- file.path(tempdir(), \"table.tex\")\ntt(mtcars[1:4, 1:4]) |> save_tt(filename)", "crumbs": [ "Tutorial (PDF)", - "Tutorial", - "Format" + "Functions", + "`save_tt`" ] }, { - "objectID": "vignettes/format.html#custom-functions", - "href": "vignettes/format.html#custom-functions", - "title": "Formatting", + "objectID": "man/save_tt.html#save-a-tiny-table-to-file", + "href": "man/save_tt.html#save-a-tiny-table-to-file", + "title": "tinytable", "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 \n \n \n \n \n mpg\n cyl\n disp\n hp\n drat\n \n \n \n \n \n 21 mpg\n 6\n 160\n 110\n 3.9\n \n \n 21 mpg\n 6\n 160\n 110\n 3.9\n \n \n 22.8 mpg\n 4\n 108\n 93\n 3.8\n \n \n 21.4 mpg\n 6\n 258\n 110\n 3.1\n \n \n \n \n\n\n\nFor example, the scales package which is used internally by ggplot2 provides a bunch of useful tools for formatting (e.g. dates, numbers, percents, logs, currencies, etc.). The label_*() functions can be passed to the fn argument.\nNote that we call format_tt(escape = TRUE) at the end of the pipeline because the column names and cells include characters that need to be escaped in LaTeX: _, %, and $. This last call is superfluous in HTML.\n\nthumbdrives <- data.frame(\n date_lookup = as.Date(c(\"2024-01-15\", \"2024-01-18\", \"2024-01-14\", \"2024-01-16\")),\n price = c(18.49, 19.99, 24.99, 24.99),\n price_rank = c(1, 2, 3, 3),\n memory = c(16e9, 12e9, 10e9, 8e9),\n speed_benchmark = c(0.6, 0.73, 0.82, 0.99)\n)\n\ntt(thumbdrives) |>\n format_tt(j = 1, fn = scales::label_date(\"%e %b\", locale = \"fr\")) |>\n format_tt(j = 2, fn = scales::label_currency()) |>\n format_tt(j = 3, fn = scales::label_ordinal()) |> \n format_tt(j = 4, fn = scales::label_bytes()) |> \n format_tt(j = 5, fn = scales::label_percent()) |>\n format_tt(escape = TRUE)\n\n\n\n \n\n \n \n \n \n \n \n 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": "This function saves an object of class tinytable to a specified file and format, with an option to overwrite existing files.\n\n\n\nsave_tt(x, output, overwrite = FALSE)\n\n\n\n\n\n\n\nx\n\n\nThe tinytable object to be saved.\n\n\n\n\noutput\n\n\nString or file path.\n\n\nIf output is \"markdown\", \"latex\", \"html\", or \"typst\", the table is returned in a string as an R object.\n\n\nIf output is a valid file path, the table is saved to file. The supported extensions are: .docx, .html, .png, .pdf, .tex, .typ, and .md (with aliases .txt, .Rmd and .qmd).\n\n\n\n\n\n\noverwrite\n\n\nA logical value indicating whether to overwrite an existing file.\n\n\n\n\n\n\nA string or TRUE when the table is written to file.\n\n\n\n\nlibrary(\"tinytable\")\n\nlibrary(tinytable)\nx <- mtcars[1:4, 1:5]\n\nfn <- file.path(tempdir(), \"test.html\")\ntt(x) |> save_tt(fn, overwrite = TRUE)\n\nlibrary(tinytable)\nfilename <- file.path(tempdir(), \"table.tex\")\ntt(mtcars[1:4, 1:4]) |> save_tt(filename)", "crumbs": [ "Tutorial (PDF)", - "Tutorial", - "Format" + "Functions", + "`save_tt`" ] }, { - "objectID": "vignettes/format.html#quarto-data-processing", - "href": "vignettes/format.html#quarto-data-processing", - "title": "Formatting", + "objectID": "CITATION.html", + "href": "CITATION.html", + "title": "Citation", "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 \n \n\n\n\nThing\nCitation\n\n\n\n\nqwerty\nLovelace (1842)\n\n\n\n\n \n\n\n\nSome users may want to apply Quarto data processing to all tables. This can be done with themes:\n\ntheme_quarto <- function(x) format_tt(x, quarto = TRUE)\noptions(tinytable_tt_theme = theme_quarto)\n\ntt(k)\n\n\n\n \n\n \n \n \n\n\n\nThing\nCitation\n\n\n\n\nqwerty\nLovelace (1842)\n\n\n\n\n \n\n\n\nBack to normal:\n\noptions(tinytable_tt_theme = NULL)\n\nAlternatively, users can set a global option to process all tables in Quarto, but they will then have to mark each cell with special content using format_tt(quarto):\n\noptions(tinytable_quarto_disable_processing = FALSE)\n\ntt(x)\n\n\n\n \n\n \n \n \n\n\n\nmpg\ncyl\ndisp\nhp\ndrat\n\n\n\n\n21.0\n6\n160\n110\n3.90\n\n\n21.0\n6\n160\n110\n3.90\n\n\n22.8\n4\n108\n93\n3.85\n\n\n21.4\n6\n258\n110\n3.08\n\n\n\n\n \n\n\n\nNotice that Quarto is now processing the table, so we lose the default tinytable theme and get the default striped Quarto look.\nBack to normal:\n\noptions(tinytable_quarto_disable_processing = TRUE)", + "text": "Citation\nTo cite package ‘tinytable’ in publications use:\n\nArel-Bundock V (????). tinytable: Simple and Configurable Tables in ‘HTML’, ‘LaTeX’, ‘Markdown’, ‘Word’, ‘PNG’, ‘PDF’, and ‘Typst’ Formats. R package version 0.3.0.32, https://vincentarelbundock.github.io/tinytable/.", "crumbs": [ "Tutorial (PDF)", - "Tutorial", - "Format" + "Citation" ] }, { - "objectID": "vignettes/theme.html", - "href": "vignettes/theme.html", - "title": "Themes", + "objectID": "LICENSE.html", + "href": "LICENSE.html", + "title": "GNU General Public License", "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 \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\ntt(x) |> theme_tt(\"striped\")\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\ntt(x, theme = \"grid\")\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\ntt(x, theme = \"bootstrap\")\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\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 \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\ntt(mtcars[1:3, 1:3])\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\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{tabular}{lllll}\n\\hline\nmpg & cyl & disp & hp & drat \\\\ \\hline\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\\hline\n\\end{tabular} \n\n\n\n\n\nLaTeX only.\n\n\n\nLaTeX only.\n\n\n\nLaTeX only.", + "text": "Version 3, 29 June 2007\nCopyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>\nEveryone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.\n\n\nThe GNU General Public License is a free, copyleft license for software and other kinds of works.\nThe licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program–to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.\nTo protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.\nFor example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.\nDevelopers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.\nFor the developers’ and authors’ protection, the GPL clearly explains that there is no warranty for this free software. For both users’ and authors’ sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.\nSome devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users’ freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.\nFinally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.\nThe precise terms and conditions for copying, distribution and modification follow.\n\n\n\n\n\n“This License” refers to version 3 of the GNU General Public License.\n“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.\n“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.\nTo “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.\nA “covered work” means either the unmodified Program or a work based on the Program.\nTo “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.\nTo “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.\nAn interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.\n\n\n\nThe “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.\nA “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.\nThe “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.\nThe “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work’s System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.\nThe Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.\nThe Corresponding Source for a work in source code form is that same work.\n\n\n\nAll rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.\nYou may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.\nConveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.\n\n\n\nNo covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.\nWhen you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work’s users, your or third parties’ legal rights to forbid circumvention of technological measures.\n\n\n\nYou may convey verbatim copies of the Program’s source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.\nYou may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.\n\n\n\nYou may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:\n\na) The work must carry prominent notices stating that you modified it, and giving a relevant date.\nb) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.\nc) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.\nd) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.\n\nA compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation’s users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.\n\n\n\nYou may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:\n\na) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.\nb) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.\nc) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.\nd) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.\ne) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.\n\nA separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.\nA “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.\n“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.\nIf you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).\nThe requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.\nCorresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.\n\n\n\n“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.\nWhen you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.\nNotwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:\n\na) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or\nb) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or\nc) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or\nd) Limiting the use for publicity purposes of names of licensors or authors of the material; or\ne) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or\nf) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.\n\nAll other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.\nIf you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.\nAdditional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.\n\n\n\nYou may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).\nHowever, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.\nMoreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.\nTermination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.\n\n\n\nYou are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.\n\n\n\nEach time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.\nAn “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party’s predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.\nYou may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.\n\n\n\nA “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor’s “contributor version”.\nA contributor’s “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.\nEach contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor’s essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.\nIn the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.\nIf you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient’s use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.\nIf, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.\nA patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.\nNothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.\n\n\n\nIf conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.\n\n\n\nNotwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.\n\n\n\nThe Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.\nEach version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.\nIf the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Program.\nLater license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.\n\n\n\nTHERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n\n\nIN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\n\n\n\nIf the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.\nEND OF TERMS AND CONDITIONS\n\n\n\n\nIf you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.\nTo do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.\n<one line to give the program's name and a brief idea of what it does.>\nCopyright (C) <year> <name of author>\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see <http://www.gnu.org/licenses/>.\nAlso add information on how to contact you by electronic and paper mail.\nIf the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:\n<program> Copyright (C) <year> <name of author>\nThis program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.\nThis is free software, and you are welcome to redistribute it\nunder certain conditions; type 'show c' for details.\nThe hypothetical commands show w and show c should show the appropriate parts of the General Public License. Of course, your program’s commands might be different; for a GUI interface, you would use an “about box”.\nYou should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.\nThe GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.", "crumbs": [ "Tutorial (PDF)", - "Tutorial", - "Themes" + "License" ] }, { - "objectID": "vignettes/theme.html#visual-themes", - "href": "vignettes/theme.html#visual-themes", - "title": "Themes", + "objectID": "LICENSE.html#preamble", + "href": "LICENSE.html#preamble", + "title": "GNU General Public License", "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 \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\ntt(x) |> theme_tt(\"striped\")\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\ntt(x, theme = \"grid\")\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\ntt(x, theme = \"bootstrap\")\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 GNU General Public License is a free, copyleft license for software and other kinds of works.\nThe licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program–to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.\nTo protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.\nFor example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.\nDevelopers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.\nFor the developers’ and authors’ protection, the GPL clearly explains that there is no warranty for this free software. For both users’ and authors’ sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.\nSome devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users’ freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.\nFinally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.\nThe precise terms and conditions for copying, distribution and modification follow.", "crumbs": [ "Tutorial (PDF)", - "Tutorial", - "Themes" + "License" ] }, { - "objectID": "vignettes/theme.html#custom-themes", - "href": "vignettes/theme.html#custom-themes", - "title": "Themes", + "objectID": "LICENSE.html#terms-and-conditions", + "href": "LICENSE.html#terms-and-conditions", + "title": "GNU General Public License", "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 \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\ntt(mtcars[1:3, 1:3])\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\noptions(tinytable_tt_theme = NULL)", + "text": "“This License” refers to version 3 of the GNU General Public License.\n“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.\n“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.\nTo “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.\nA “covered work” means either the unmodified Program or a work based on the Program.\nTo “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.\nTo “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.\nAn interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.\n\n\n\nThe “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.\nA “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.\nThe “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.\nThe “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work’s System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.\nThe Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.\nThe Corresponding Source for a work in source code form is that same work.\n\n\n\nAll rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.\nYou may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.\nConveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.\n\n\n\nNo covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.\nWhen you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work’s users, your or third parties’ legal rights to forbid circumvention of technological measures.\n\n\n\nYou may convey verbatim copies of the Program’s source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.\nYou may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.\n\n\n\nYou may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:\n\na) The work must carry prominent notices stating that you modified it, and giving a relevant date.\nb) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.\nc) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.\nd) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.\n\nA compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation’s users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.\n\n\n\nYou may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:\n\na) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.\nb) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.\nc) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.\nd) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.\ne) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.\n\nA separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.\nA “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.\n“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.\nIf you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).\nThe requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.\nCorresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.\n\n\n\n“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.\nWhen you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.\nNotwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:\n\na) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or\nb) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or\nc) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or\nd) Limiting the use for publicity purposes of names of licensors or authors of the material; or\ne) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or\nf) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.\n\nAll other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.\nIf you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.\nAdditional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.\n\n\n\nYou may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).\nHowever, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.\nMoreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.\nTermination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.\n\n\n\nYou are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.\n\n\n\nEach time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.\nAn “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party’s predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.\nYou may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.\n\n\n\nA “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor’s “contributor version”.\nA contributor’s “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.\nEach contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor’s essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.\nIn the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.\nIf you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient’s use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.\nIf, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.\nA patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.\nNothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.\n\n\n\nIf conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.\n\n\n\nNotwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.\n\n\n\nThe Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.\nEach version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.\nIf the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Program.\nLater license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.\n\n\n\nTHERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n\n\nIN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\n\n\n\nIf the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.\nEND OF TERMS AND CONDITIONS", "crumbs": [ "Tutorial (PDF)", - "Tutorial", - "Themes" + "License" ] }, { - "objectID": "vignettes/theme.html#tabular", - "href": "vignettes/theme.html#tabular", - "title": "Themes", + "objectID": "LICENSE.html#how-to-apply-these-terms-to-your-new-programs", + "href": "LICENSE.html#how-to-apply-these-terms-to-your-new-programs", + "title": "GNU General Public License", "section": "", - "text": "The 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{tabular}{lllll}\n\\hline\nmpg & cyl & disp & hp & drat \\\\ \\hline\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\\hline\n\\end{tabular}", + "text": "If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.\nTo do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.\n<one line to give the program's name and a brief idea of what it does.>\nCopyright (C) <year> <name of author>\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see <http://www.gnu.org/licenses/>.\nAlso add information on how to contact you by electronic and paper mail.\nIf the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:\n<program> Copyright (C) <year> <name of author>\nThis program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.\nThis is free software, and you are welcome to redistribute it\nunder certain conditions; type 'show c' for details.\nThe hypothetical commands show w and show c should show the appropriate parts of the General Public License. Of course, your program’s commands might be different; for a GUI interface, you would use an “about box”.\nYou should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.\nThe GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.", "crumbs": [ "Tutorial (PDF)", - "Tutorial", - "Themes" + "License" ] }, { - "objectID": "vignettes/theme.html#resize", - "href": "vignettes/theme.html#resize", - "title": "Themes", + "objectID": "man/tt.html", + "href": "man/tt.html", + "title": "tinytable", "section": "", - "text": "LaTeX only.", + "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 = get_option(\"tinytable_tt_digits\", default = NULL),\n caption = get_option(\"tinytable_tt_caption\", default = NULL),\n notes = get_option(\"tinytable_tt_notes\", default = NULL),\n width = get_option(\"tinytable_tt_width\", default = NULL),\n theme = get_option(\"tinytable_tt_theme\", default = NULL),\n rownames = get_option(\"tinytable_tt_rownames\", default = FALSE),\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\nrownames\n\n\nLogical. If TRUE, rownames are included as the first column\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\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\nEXPERIMENTAL options(tinytable_html_mathjax = TRUE) inserts MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\n\n\n\noptions(tinytable_pdf_clean = TRUE) deletes temporary and log files.\n\n\noptions(tinytable_pdf_engine = “xelatex”): \"xelatex\", \"pdflatex\", \"lualatex\"\n\n\n\n\n\noptions(tinytable_markdown_hlines = TRUE) sets whether gridlines are included in markdown tables. This should be true for docx conversion.\n\n\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 \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\ntt(x,\n theme = \"striped\",\n width = 0.5,\n caption = \"Data about cars.\")\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\ntt(x, notes = \"Hello World!\")\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\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 \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12.43568", "crumbs": [ "Tutorial (PDF)", - "Tutorial", - "Themes" + "Functions", + "`tt`" ] }, { - "objectID": "vignettes/theme.html#placement", - "href": "vignettes/theme.html#placement", - "title": "Themes", + "objectID": "man/tt.html#draw-a-tiny-table", + "href": "man/tt.html#draw-a-tiny-table", + "title": "tinytable", "section": "", - "text": "LaTeX only.", + "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 = get_option(\"tinytable_tt_digits\", default = NULL),\n caption = get_option(\"tinytable_tt_caption\", default = NULL),\n notes = get_option(\"tinytable_tt_notes\", default = NULL),\n width = get_option(\"tinytable_tt_width\", default = NULL),\n theme = get_option(\"tinytable_tt_theme\", default = NULL),\n rownames = get_option(\"tinytable_tt_rownames\", default = FALSE),\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\nrownames\n\n\nLogical. If TRUE, rownames are included as the first column\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\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\nEXPERIMENTAL options(tinytable_html_mathjax = TRUE) inserts MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\n\n\n\noptions(tinytable_pdf_clean = TRUE) deletes temporary and log files.\n\n\noptions(tinytable_pdf_engine = “xelatex”): \"xelatex\", \"pdflatex\", \"lualatex\"\n\n\n\n\n\noptions(tinytable_markdown_hlines = TRUE) sets whether gridlines are included in markdown tables. This should be true for docx conversion.\n\n\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 \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\ntt(x,\n theme = \"striped\",\n width = 0.5,\n caption = \"Data about cars.\")\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\ntt(x, notes = \"Hello World!\")\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\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 \n \n \n \n \n x\n \n \n \n \n \n 0.00012\n \n \n 12.43568", "crumbs": [ "Tutorial (PDF)", - "Tutorial", - "Themes" + "Functions", + "`tt`" ] }, { - "objectID": "vignettes/theme.html#multipage", - "href": "vignettes/theme.html#multipage", - "title": "Themes", + "objectID": "man/plot_tt.html", + "href": "man/plot_tt.html", + "title": "tinytable", "section": "", - "text": "LaTeX only.", + "text": "The plot_tt() function allows for the insertion of images and inline plots into tinytable objects. This function can handle both local and web-based images.\n\n\n\nplot_tt(\n x,\n i = NULL,\n j = NULL,\n fun = NULL,\n data = NULL,\n color = \"black\",\n xlim = NULL,\n height = 1,\n asp = 1/3,\n images = NULL,\n assets = \"tinytable_assets\",\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA tinytable object.\n\n\n\n\ni\n\n\nInteger vector, the row indices where images are to be inserted. If NULL, images will be inserted in all rows.\n\n\n\n\nj\n\n\nInteger vector, the column indices where images are to be inserted. If NULL, images will be inserted in all columns.\n\n\n\n\nfun\n\n\nString or function to generate inline plots.\n\n\nString: \"histogram\", \"density\", \"bar\", \"line\"\n\n\nFunctions that return ggplot2 objects.\n\n\nFunctions that return another function which generates a base R plot, ex: function(x) {function() hist(x)}\n\n\nSee the tutorial on the tinytable website for more information.\n\n\n\n\n\n\ndata\n\n\na list of data frames or vectors to be used by the plotting functions in fun.\n\n\n\n\ncolor\n\n\nstring Name of color to use for inline plots (passed to the col argument base graphics plots in R).\n\n\n\n\nxlim\n\n\nNumeric vector of length 2.\n\n\n\n\nheight\n\n\nNumeric, the height of the images in the table in em units.\n\n\n\n\nasp\n\n\nNumeric, aspect ratio of the plots (height / width).\n\n\n\n\nimages\n\n\nCharacter vector, the paths to the images to be inserted. Paths are relative to the main table file or Quarto (Rmarkdown) document.\n\n\n\n\nassets\n\n\nPath to the directory where generated assets are stored. This path is relative to the location where a table is saved.\n\n\n\n\n…\n\n\nExtra arguments are passed to the function in fun. Important: Custom plotting functions must always have … as an argument.\n\n\n\n\n\n\nThe plot_tt() can insert images and inline plots into tables.\n\n\n\nA modified tinytable object with images or plots inserted.", + "crumbs": [ + "Tutorial (PDF)", + "Functions", + "`plot_tt`" + ] + }, + { + "objectID": "man/plot_tt.html#insert-images-and-inline-plots-into-tinytable-objects", + "href": "man/plot_tt.html#insert-images-and-inline-plots-into-tinytable-objects", + "title": "tinytable", + "section": "", + "text": "The plot_tt() function allows for the insertion of images and inline plots into tinytable objects. This function can handle both local and web-based images.\n\n\n\nplot_tt(\n x,\n i = NULL,\n j = NULL,\n fun = NULL,\n data = NULL,\n color = \"black\",\n xlim = NULL,\n height = 1,\n asp = 1/3,\n images = NULL,\n assets = \"tinytable_assets\",\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA tinytable object.\n\n\n\n\ni\n\n\nInteger vector, the row indices where images are to be inserted. If NULL, images will be inserted in all rows.\n\n\n\n\nj\n\n\nInteger vector, the column indices where images are to be inserted. If NULL, images will be inserted in all columns.\n\n\n\n\nfun\n\n\nString or function to generate inline plots.\n\n\nString: \"histogram\", \"density\", \"bar\", \"line\"\n\n\nFunctions that return ggplot2 objects.\n\n\nFunctions that return another function which generates a base R plot, ex: function(x) {function() hist(x)}\n\n\nSee the tutorial on the tinytable website for more information.\n\n\n\n\n\n\ndata\n\n\na list of data frames or vectors to be used by the plotting functions in fun.\n\n\n\n\ncolor\n\n\nstring Name of color to use for inline plots (passed to the col argument base graphics plots in R).\n\n\n\n\nxlim\n\n\nNumeric vector of length 2.\n\n\n\n\nheight\n\n\nNumeric, the height of the images in the table in em units.\n\n\n\n\nasp\n\n\nNumeric, aspect ratio of the plots (height / width).\n\n\n\n\nimages\n\n\nCharacter vector, the paths to the images to be inserted. Paths are relative to the main table file or Quarto (Rmarkdown) document.\n\n\n\n\nassets\n\n\nPath to the directory where generated assets are stored. This path is relative to the location where a table is saved.\n\n\n\n\n…\n\n\nExtra arguments are passed to the function in fun. Important: Custom plotting functions must always have … as an argument.\n\n\n\n\n\n\nThe plot_tt() can insert images and inline plots into tables.\n\n\n\nA modified tinytable object with images or plots inserted.", + "crumbs": [ + "Tutorial (PDF)", + "Functions", + "`plot_tt`" + ] + }, + { + "objectID": "man/theme_tt.html", + "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\": Remove 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\nSet globally with options(“tinytable_theme_resize_width” = 0.9)\n\n\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\nSet globally with options(“tinytable_theme_resize_direction” = “down”)\n\n\n\n\nmultipage\n\n\nrowhead: Non-negative integer. The number of header rows to repeat on each page.\n\n\nSet globally with options(“tinytable_theme_multipage_rowhead” = 1L)\n\n\n\n\nrowfoot: Non-negative integer. The number of footer rows to repeat on each page.\n\n\nSet globally with options(“tinytable_theme_multipage_rowfoot” = 1L)\n\n\n\n\ntabular\n\n\nstyle:\n\n\n\"tabular\": Drop all LaTeX dependencies and floating environments, except \\begin{tabular}\n\n\n\"tabularray\": Drop all LaTeX dependencies and floating environments, except \\begin{tblr}\n\n\nSet globally with options(“tinytable_theme_tabular_style” = “tblr”)\n\n\n\n\nplacement\n\n\nhorizontal (Typst only): \"l\", \"c\", or \"r\" to align the table horizontally in the page.\n\n\nSet globally with options(“tinytable_theme_placement_horizontal” = “l”)\n\n\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\nSet globally with options(“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 \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\ntt(x) |> theme_tt(\"striped\")\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# 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", + "`theme_tt`" + ] + }, + { + "objectID": "man/theme_tt.html#themes-for-tinytable", + "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\": Remove 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\nSet globally with options(“tinytable_theme_resize_width” = 0.9)\n\n\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\nSet globally with options(“tinytable_theme_resize_direction” = “down”)\n\n\n\n\nmultipage\n\n\nrowhead: Non-negative integer. The number of header rows to repeat on each page.\n\n\nSet globally with options(“tinytable_theme_multipage_rowhead” = 1L)\n\n\n\n\nrowfoot: Non-negative integer. The number of footer rows to repeat on each page.\n\n\nSet globally with options(“tinytable_theme_multipage_rowfoot” = 1L)\n\n\n\n\ntabular\n\n\nstyle:\n\n\n\"tabular\": Drop all LaTeX dependencies and floating environments, except \\begin{tabular}\n\n\n\"tabularray\": Drop all LaTeX dependencies and floating environments, except \\begin{tblr}\n\n\nSet globally with options(“tinytable_theme_tabular_style” = “tblr”)\n\n\n\n\nplacement\n\n\nhorizontal (Typst only): \"l\", \"c\", or \"r\" to align the table horizontally in the page.\n\n\nSet globally with options(“tinytable_theme_placement_horizontal” = “l”)\n\n\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\nSet globally with options(“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 \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\ntt(x) |> theme_tt(\"striped\")\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# 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", + "`theme_tt`" + ] + }, + { + "objectID": "man/style_tt.html", + "href": "man/style_tt.html", + "title": "tinytable", + "section": "", + "text": "Style a Tiny Table\n\n\n\nstyle_tt(\n x,\n i = NULL,\n j = NULL,\n bold = FALSE,\n italic = FALSE,\n monospace = FALSE,\n underline = FALSE,\n strikeout = FALSE,\n color = NULL,\n background = NULL,\n fontsize = NULL,\n align = NULL,\n alignv = NULL,\n colspan = NULL,\n rowspan = NULL,\n indent = 0,\n line = NULL,\n line_color = \"black\",\n line_width = 0.1,\n finalize = NULL,\n tabularray_inner = NULL,\n tabularray_outer = NULL,\n bootstrap_class = NULL,\n bootstrap_css = NULL,\n bootstrap_css_rule = NULL,\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA table object created by tt().\n\n\n\n\ni\n\n\nRow indices where the styling should be applied. Can be a single value or a vector. i=0 is the header, and negative values are higher level headers. If colspan is used, i must be of length 1.\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\nbold\n\n\nLogical; if TRUE, text is styled in bold.\n\n\n\n\nitalic\n\n\nLogical; if TRUE, text is styled in italic.\n\n\n\n\nmonospace\n\n\nLogical; if TRUE, text is styled in monospace font.\n\n\n\n\nunderline\n\n\nLogical; if TRUE, text is underlined.\n\n\n\n\nstrikeout\n\n\nLogical; if TRUE, text has a strike through line.\n\n\n\n\ncolor\n\n\nText color. There are several ways to specify colors, depending on the output format.\n\n\nHTML:\n\n\nHex code composed of # and 6 characters, ex: #CC79A7.\n\n\nKeywords: black, silver, gray, white, maroon, red, purple, fuchsia, green, lime, olive, yellow, navy, blue, teal, aqua\n\n\n\n\nLaTeX:\n\n\nHex code composed of # and 6 characters, ex: \"#CC79A7\". See the section below for instructions to add in LaTeX preambles.\n\n\nKeywords: black, blue, brown, cyan, darkgray, gray, green, lightgray, lime, magenta, olive, orange, pink, purple, red, teal, violet, white, yellow.\n\n\nColor blending using xcolor, ex: white!80!blue, green!20!red’.\n\n\nColor names with luminance levels from the ninecolors package (ex: \"azure4\", \"magenta8\", \"teal2\", \"gray1\", \"olive3\").\n\n\n\n\n\n\n\n\nbackground\n\n\nBackground color. Specified as a color name or hexadecimal code. Can be NULL for default color.\n\n\n\n\nfontsize\n\n\nFont size in em units. Can be NULL for default size.\n\n\n\n\nalign\n\n\nA single character or a string with a number of characters equal to the number of columns in j. Valid characters include ‘c’ (center), ‘l’ (left), ‘r’ (right), ‘d’ (decimal). Decimal alignment is only available in LaTeX via the siunitx package. 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 and j.\n\n\n\n\nalignv\n\n\nA single character specifying vertical alignment. Valid characters include ‘t’ (top), ‘m’ (middle), ‘b’ (bottom).\n\n\n\n\ncolspan\n\n\nNumber of columns a cell should span. i and j must be of length 1.\n\n\n\n\nrowspan\n\n\nNumber of rows a cell should span. i and j must be of length 1.\n\n\n\n\nindent\n\n\nText indentation in em units. Positive values only.\n\n\n\n\nline\n\n\nString determines if solid lines (rules or borders) should be drawn around the cell, row, or column.\n\n\n\"t\": top\n\n\n\"b\": bottom\n\n\n\"l\": left\n\n\n\"r\": right\n\n\nCan be combined such as: \"lbt\" to draw borders at the left, bottom, and top.\n\n\n\n\n\n\nline_color\n\n\nColor of the line. See the color argument for details.\n\n\n\n\nline_width\n\n\nWidth of the line in em units (default: 0.1).\n\n\n\n\nfinalize\n\n\nA function applied to the table object at the very end of table-building, for post-processing. For example, the function could use regular expressions to add LaTeX commands to the text version of the table hosted in x@table_string, or it could programmatically change the caption in x@caption.\n\n\n\n\ntabularray_inner\n\n\nA string that specifies the \"inner\" settings of a tabularray LaTeX table.\n\n\n\n\ntabularray_outer\n\n\nA string that specifies the \"outer\" settings of a tabularray LaTeX table.\n\n\n\n\nbootstrap_class\n\n\nString. Bootstrap table class such as “table”, “table table-dark” or “table table-dark table-hover”. See the bootstrap documentation.\n\n\n\n\nbootstrap_css\n\n\nCharacter vector. CSS style declarations to be applied to every cell defined by i and j (ex: “font-weight: bold”).\n\n\n\n\nbootstrap_css_rule\n\n\nString. Complete CSS rules (with curly braces, semicolon, etc.) that apply to the table class specified by the bootstrap_class argument.\n\n\n\n\n…\n\n\nextra arguments are ignored\n\n\n\n\n\n\nThis function applies styling to a table created by tt(). It allows customization of text style (bold, italic, monospace), text and background colors, font size, cell width, text alignment, column span, and indentation. The function also supports passing native instructions to LaTeX (tabularray) and HTML (bootstrap) formats.\nNote: Markdown and Word tables only support these styles: italic, bold, strikeout. Moreover, the style_tt() function cannot be used to style headers inserted by the group_tt() function; instead, you should style the headers directly in the header definition using markdown syntax: group_tt(i = list(“italic header” = 2)). These limitations are due to the fact that there is no markdown syntax for the other options, and that we create Word documents by converting a markdown table to .docx via the Pandoc software.\n\n\n\nAn object of class tt representing the table.\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\nlibrary(\"tinytable\")\n\n\n\nif (knitr::is_html_output()) options(tinytable_print_output = \"html\")\n\nlibrary(tinytable)\n\ntt(mtcars[1:5, 1:6])\n\n# Alignment\ntt(mtcars[1:5, 1:6]) |> \n style_tt(j = 1:5, align = \"lcccr\")\n\n# Colors and styles\ntt(mtcars[1:5, 1:6]) |> \n style_tt(i = 2:3, background = \"black\", color = \"orange\", bold = TRUE)\n\n# column selection with `j``\ntt(mtcars[1:5, 1:6]) |> \n style_tt(j = 5:6, background = \"pink\")\n\ntt(mtcars[1:5, 1:6]) |>\n style_tt(j = \"drat|wt\", background = \"pink\")\n\ntt(mtcars[1:5, 1:6]) |>\n style_tt(j = c(\"drat\", \"wt\"), background = \"pink\")\n\ntt(mtcars[1:5, 1:6], theme = \"void\") |>\n 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 \ntt(mtcars[1:5, 1:6], theme = \"void\") |>\n style_tt(\n i=0:3,\n j=1:3,\n line=\"tblr\",\n line_width=0.4,\n line_color=\"teal\")\n \ntt(mtcars[1:5, 1:6], theme = \"bootstrap\") |>\n style_tt(\n i = c(2,5),\n j = 3,\n strikeout = TRUE,\n fontsize = 0.7)\n \ntt(mtcars[1:5, 1:6]) |>\n style_tt(bootstrap_class = \"table table-dark table-hover\")\n\n\ninner <- \"\ncolumn{1-4}={halign=c},\nhlines = {fg=white},\nvlines = {fg=white},\ncell{1,6}{odd} = {bg=teal7},\ncell{1,6}{even} = {bg=green7},\ncell{2,4}{1,4} = {bg=red7},\ncell{3,5}{1,4} = {bg=purple7},\ncell{2}{2} = {r=4,c=2}{bg=azure7},\n\"\ntt(mtcars[1:5, 1:4], theme = \"void\") |>\n style_tt(tabularray_inner = inner)", + "crumbs": [ + "Tutorial (PDF)", + "Functions", + "`style_tt`" + ] + }, + { + "objectID": "man/style_tt.html#style-a-tiny-table", + "href": "man/style_tt.html#style-a-tiny-table", + "title": "tinytable", + "section": "", + "text": "Style a Tiny Table\n\n\n\nstyle_tt(\n x,\n i = NULL,\n j = NULL,\n bold = FALSE,\n italic = FALSE,\n monospace = FALSE,\n underline = FALSE,\n strikeout = FALSE,\n color = NULL,\n background = NULL,\n fontsize = NULL,\n align = NULL,\n alignv = NULL,\n colspan = NULL,\n rowspan = NULL,\n indent = 0,\n line = NULL,\n line_color = \"black\",\n line_width = 0.1,\n finalize = NULL,\n tabularray_inner = NULL,\n tabularray_outer = NULL,\n bootstrap_class = NULL,\n bootstrap_css = NULL,\n bootstrap_css_rule = NULL,\n ...\n)\n\n\n\n\n\n\n\nx\n\n\nA table object created by tt().\n\n\n\n\ni\n\n\nRow indices where the styling should be applied. Can be a single value or a vector. i=0 is the header, and negative values are higher level headers. If colspan is used, i must be of length 1.\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\nbold\n\n\nLogical; if TRUE, text is styled in bold.\n\n\n\n\nitalic\n\n\nLogical; if TRUE, text is styled in italic.\n\n\n\n\nmonospace\n\n\nLogical; if TRUE, text is styled in monospace font.\n\n\n\n\nunderline\n\n\nLogical; if TRUE, text is underlined.\n\n\n\n\nstrikeout\n\n\nLogical; if TRUE, text has a strike through line.\n\n\n\n\ncolor\n\n\nText color. There are several ways to specify colors, depending on the output format.\n\n\nHTML:\n\n\nHex code composed of # and 6 characters, ex: #CC79A7.\n\n\nKeywords: black, silver, gray, white, maroon, red, purple, fuchsia, green, lime, olive, yellow, navy, blue, teal, aqua\n\n\n\n\nLaTeX:\n\n\nHex code composed of # and 6 characters, ex: \"#CC79A7\". See the section below for instructions to add in LaTeX preambles.\n\n\nKeywords: black, blue, brown, cyan, darkgray, gray, green, lightgray, lime, magenta, olive, orange, pink, purple, red, teal, violet, white, yellow.\n\n\nColor blending using xcolor, ex: white!80!blue, green!20!red’.\n\n\nColor names with luminance levels from the ninecolors package (ex: \"azure4\", \"magenta8\", \"teal2\", \"gray1\", \"olive3\").\n\n\n\n\n\n\n\n\nbackground\n\n\nBackground color. Specified as a color name or hexadecimal code. Can be NULL for default color.\n\n\n\n\nfontsize\n\n\nFont size in em units. Can be NULL for default size.\n\n\n\n\nalign\n\n\nA single character or a string with a number of characters equal to the number of columns in j. Valid characters include ‘c’ (center), ‘l’ (left), ‘r’ (right), ‘d’ (decimal). Decimal alignment is only available in LaTeX via the siunitx package. 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 and j.\n\n\n\n\nalignv\n\n\nA single character specifying vertical alignment. Valid characters include ‘t’ (top), ‘m’ (middle), ‘b’ (bottom).\n\n\n\n\ncolspan\n\n\nNumber of columns a cell should span. i and j must be of length 1.\n\n\n\n\nrowspan\n\n\nNumber of rows a cell should span. i and j must be of length 1.\n\n\n\n\nindent\n\n\nText indentation in em units. Positive values only.\n\n\n\n\nline\n\n\nString determines if solid lines (rules or borders) should be drawn around the cell, row, or column.\n\n\n\"t\": top\n\n\n\"b\": bottom\n\n\n\"l\": left\n\n\n\"r\": right\n\n\nCan be combined such as: \"lbt\" to draw borders at the left, bottom, and top.\n\n\n\n\n\n\nline_color\n\n\nColor of the line. See the color argument for details.\n\n\n\n\nline_width\n\n\nWidth of the line in em units (default: 0.1).\n\n\n\n\nfinalize\n\n\nA function applied to the table object at the very end of table-building, for post-processing. For example, the function could use regular expressions to add LaTeX commands to the text version of the table hosted in x@table_string, or it could programmatically change the caption in x@caption.\n\n\n\n\ntabularray_inner\n\n\nA string that specifies the \"inner\" settings of a tabularray LaTeX table.\n\n\n\n\ntabularray_outer\n\n\nA string that specifies the \"outer\" settings of a tabularray LaTeX table.\n\n\n\n\nbootstrap_class\n\n\nString. Bootstrap table class such as “table”, “table table-dark” or “table table-dark table-hover”. See the bootstrap documentation.\n\n\n\n\nbootstrap_css\n\n\nCharacter vector. CSS style declarations to be applied to every cell defined by i and j (ex: “font-weight: bold”).\n\n\n\n\nbootstrap_css_rule\n\n\nString. Complete CSS rules (with curly braces, semicolon, etc.) that apply to the table class specified by the bootstrap_class argument.\n\n\n\n\n…\n\n\nextra arguments are ignored\n\n\n\n\n\n\nThis function applies styling to a table created by tt(). It allows customization of text style (bold, italic, monospace), text and background colors, font size, cell width, text alignment, column span, and indentation. The function also supports passing native instructions to LaTeX (tabularray) and HTML (bootstrap) formats.\nNote: Markdown and Word tables only support these styles: italic, bold, strikeout. Moreover, the style_tt() function cannot be used to style headers inserted by the group_tt() function; instead, you should style the headers directly in the header definition using markdown syntax: group_tt(i = list(“italic header” = 2)). These limitations are due to the fact that there is no markdown syntax for the other options, and that we create Word documents by converting a markdown table to .docx via the Pandoc software.\n\n\n\nAn object of class tt representing the table.\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\nlibrary(\"tinytable\")\n\n\n\nif (knitr::is_html_output()) options(tinytable_print_output = \"html\")\n\nlibrary(tinytable)\n\ntt(mtcars[1:5, 1:6])\n\n# Alignment\ntt(mtcars[1:5, 1:6]) |> \n style_tt(j = 1:5, align = \"lcccr\")\n\n# Colors and styles\ntt(mtcars[1:5, 1:6]) |> \n style_tt(i = 2:3, background = \"black\", color = \"orange\", bold = TRUE)\n\n# column selection with `j``\ntt(mtcars[1:5, 1:6]) |> \n style_tt(j = 5:6, background = \"pink\")\n\ntt(mtcars[1:5, 1:6]) |>\n style_tt(j = \"drat|wt\", background = \"pink\")\n\ntt(mtcars[1:5, 1:6]) |>\n style_tt(j = c(\"drat\", \"wt\"), background = \"pink\")\n\ntt(mtcars[1:5, 1:6], theme = \"void\") |>\n 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 \ntt(mtcars[1:5, 1:6], theme = \"void\") |>\n style_tt(\n i=0:3,\n j=1:3,\n line=\"tblr\",\n line_width=0.4,\n line_color=\"teal\")\n \ntt(mtcars[1:5, 1:6], theme = \"bootstrap\") |>\n style_tt(\n i = c(2,5),\n j = 3,\n strikeout = TRUE,\n fontsize = 0.7)\n \ntt(mtcars[1:5, 1:6]) |>\n style_tt(bootstrap_class = \"table table-dark table-hover\")\n\n\ninner <- \"\ncolumn{1-4}={halign=c},\nhlines = {fg=white},\nvlines = {fg=white},\ncell{1,6}{odd} = {bg=teal7},\ncell{1,6}{even} = {bg=green7},\ncell{2,4}{1,4} = {bg=red7},\ncell{3,5}{1,4} = {bg=purple7},\ncell{2}{2} = {r=4,c=2}{bg=azure7},\n\"\ntt(mtcars[1:5, 1:4], theme = \"void\") |>\n style_tt(tabularray_inner = inner)", + "crumbs": [ + "Tutorial (PDF)", + "Functions", + "`style_tt`" + ] + }, + { + "objectID": "man/print.tinytable.html", + "href": "man/print.tinytable.html", + "title": "tinytable", + "section": "", + "text": "This function is called automatically by R whenever a tinytable object is anprinted to the console or in an HTML viewer pane.\n\n\n\n## S3 method for class 'tinytable'\nprint(x, output = get_option(\"tinytable_print_output\", default = NULL), ...)\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\noutput\n\n\nformat in which a Tiny Table is printed: NULL or one of “latex”, “markdown”, “html”, “typst”, “dataframe”. If NULL, the output is chosen based on these rules:\n\n\nWhen called from a script in non-interactive mode, the default is \"markdown\" (interactive() == FALSE).\n\n\nWhen called interactively in RStudio, the default is to display an HTML table in the viewer pane.\n\n\nWhen called interactively in another development environment, the default is \"markdown\".\n\n\nThe default print output can be changed for an entire R session by calling: options(tinytable_print_output = “html”)\n\n\nThe default print output can be changed for a single tinytable object by modifying the output S4 slot.\n\n\n\n\n\n\n…\n\n\nOther arguments are ignored.\n\n\n\n\n\n\nlaunch a browser window or cat() the table to console.", + "crumbs": [ + "Tutorial (PDF)", + "Functions", + "`print`" + ] + }, + { + "objectID": "man/print.tinytable.html#print-display-or-convert-a-tinytable-object", + "href": "man/print.tinytable.html#print-display-or-convert-a-tinytable-object", + "title": "tinytable", + "section": "", + "text": "This function is called automatically by R whenever a tinytable object is anprinted to the console or in an HTML viewer pane.\n\n\n\n## S3 method for class 'tinytable'\nprint(x, output = get_option(\"tinytable_print_output\", default = NULL), ...)\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\noutput\n\n\nformat in which a Tiny Table is printed: NULL or one of “latex”, “markdown”, “html”, “typst”, “dataframe”. If NULL, the output is chosen based on these rules:\n\n\nWhen called from a script in non-interactive mode, the default is \"markdown\" (interactive() == FALSE).\n\n\nWhen called interactively in RStudio, the default is to display an HTML table in the viewer pane.\n\n\nWhen called interactively in another development environment, the default is \"markdown\".\n\n\nThe default print output can be changed for an entire R session by calling: options(tinytable_print_output = “html”)\n\n\nThe default print output can be changed for a single tinytable object by modifying the output S4 slot.\n\n\n\n\n\n\n…\n\n\nOther arguments are ignored.\n\n\n\n\n\n\nlaunch a browser window or cat() the table to console.", + "crumbs": [ + "Tutorial (PDF)", + "Functions", + "`print`" + ] + }, + { + "objectID": "vignettes/plot.html", + "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 \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\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 \n \n \n \n \n R\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 \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\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 \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\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 \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\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 \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\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 \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", - "Themes" + "Plots and images" ] }, { - "objectID": "vignettes/style.html", - "href": "vignettes/style.html", - "title": "Style", + "objectID": "vignettes/plot.html#inserting-images-in-tables", + "href": "vignettes/plot.html#inserting-images-in-tables", + "title": "Plots and images", "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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\ntt(x) |> style_tt(j = \"mpg|drat\", color = \"orange\")\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\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 \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\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 \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\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 \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\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 \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\ntt(dat) |> style_tt(j = 1:3, align = \"lcr\")\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\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 \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\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 \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\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 \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\nHere is the original table for comparison:\n\ntt(x)\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\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 \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\nThe rowspan feature is also useful to create multi-row labels. For example, in this table there is a linebreak, but all the text fits in a single cell:\n\ntab <- data.frame(Letters = c(\"A<br>B\", \"\"), Numbers = c(\"First\", \"Second\"))\n\ntt(tab) |>\n style_tt(bootstrap_class = \"table-bordered\")\n\n\n\n \n\n \n \n \n \n \n \n Letters\n Numbers\n \n \n \n \n \n AB\n First \n \n \n \n Second\n \n \n \n \n\n\n\nNow, we use colspan to ensure that that cells in the first column take up less space and are combined into one:\n\ntt(tab) |>\n style_tt(bootstrap_class = \"table-bordered\") |>\n style_tt(1, 1, rowspan = 2)\n\n\n\n \n\n \n \n \n \n \n \n Letters\n Numbers\n \n \n \n \n \n AB\n First \n \n \n \n Second\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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\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 bootstrap_css = \"padding-right: .2em; padding-top: 2em;\",\n tabularray_inner = \"rowsep={2em}, colsep = {.2em}\"\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\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": "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 \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\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 \n \n \n \n \n R", "crumbs": [ "Tutorial (PDF)", "Tutorial", - "Style" + "Plots and images" ] }, { - "objectID": "vignettes/style.html#cells-rows-columns", - "href": "vignettes/style.html#cells-rows-columns", - "title": "Style", + "objectID": "vignettes/plot.html#inline-plots", + "href": "vignettes/plot.html#inline-plots", + "title": "Plots and images", "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 \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\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 \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\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 \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\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 \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\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 \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\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 \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\ntt(x) |> style_tt(j = \"mpg|drat\", color = \"orange\")\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\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 \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\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 \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": "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 \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\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 \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\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 \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\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 \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", - "Style" + "Plots and images" ] }, { - "objectID": "vignettes/style.html#colors", - "href": "vignettes/style.html#colors", - "title": "Style", + "objectID": "vignettes/plot.html#fontawesome", + "href": "vignettes/plot.html#fontawesome", + "title": "Plots and images", "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 \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\nNote that when using Hex codes in a LaTeX table, we need extra declarations in the LaTeX preamble. See ?tt for details.", + "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 \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", - "Style" + "Plots and images" ] }, { - "objectID": "vignettes/style.html#alignment", - "href": "vignettes/style.html#alignment", - "title": "Style", + "objectID": "vignettes/group.html", + "href": "vignettes/group.html", + "title": "Groups and labels", "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 \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\ntt(dat) |> style_tt(j = 1:3, align = \"lcr\")\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\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 \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": "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 \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\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\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\ntt(head(iris)) |>\n group_tt(i = list(\"After 1a\" = 2, \"After 1b\" = 2, \"After 5\" = 6))\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\ntt(head(iris)) |>\n group_tt(i = list(\"After 0\" = 1))\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\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 \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\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 \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\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 \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\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 \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", - "Style" + "Group labels" ] }, { - "objectID": "vignettes/style.html#font-size", - "href": "vignettes/style.html#font-size", - "title": "Style", + "objectID": "vignettes/group.html#rows", + "href": "vignettes/group.html#rows", + "title": "Groups and labels", "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 \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 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 \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\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\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\ntt(head(iris)) |>\n group_tt(i = list(\"After 1a\" = 2, \"After 1b\" = 2, \"After 5\" = 6))\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\ntt(head(iris)) |>\n group_tt(i = list(\"After 0\" = 1))\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\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 \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", - "Style" + "Group labels" ] }, { - "objectID": "vignettes/style.html#spanning-cells-merging-cells", - "href": "vignettes/style.html#spanning-cells-merging-cells", - "title": "Style", + "objectID": "vignettes/group.html#columns", + "href": "vignettes/group.html#columns", + "title": "Groups and labels", "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 \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\nHere is the original table for comparison:\n\ntt(x)\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\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 \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\nThe rowspan feature is also useful to create multi-row labels. For example, in this table there is a linebreak, but all the text fits in a single cell:\n\ntab <- data.frame(Letters = c(\"A<br>B\", \"\"), Numbers = c(\"First\", \"Second\"))\n\ntt(tab) |>\n style_tt(bootstrap_class = \"table-bordered\")\n\n\n\n \n\n \n \n \n \n \n \n Letters\n Numbers\n \n \n \n \n \n AB\n First \n \n \n \n Second\n \n \n \n \n\n\n\nNow, we use colspan to ensure that that cells in the first column take up less space and are combined into one:\n\ntt(tab) |>\n style_tt(bootstrap_class = \"table-bordered\") |>\n style_tt(1, 1, rowspan = 2)\n\n\n\n \n\n \n \n \n \n \n \n Letters\n Numbers\n \n \n \n \n \n AB\n First \n \n \n \n Second", + "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 \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\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 \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\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 \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", - "Style" + "Group labels" ] }, { - "objectID": "vignettes/style.html#headers", - "href": "vignettes/style.html#headers", - "title": "Style", + "objectID": "vignettes/faq.html", + "href": "vignettes/faq.html", + "title": "FAQ", "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 \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\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 \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\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 \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": "Relative widths tables: table-layout: fixed vs auto.\n\n\n\n\n\n\ntinytable uses the tabularray package from your LaTeX distribution to draw tables. tabularray, in turn, provides special tblr, talltblr, and longtblr environments to display tabular data.\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\\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\nSome users have encountered unexpected spacing behavior when generating tables that are not wrapped in a \\begin{table} environment (ex: multipage or raw tblr).\nOne issue stems from the fact that the \\begin{table} environment resets any spacing commands in the preamble or body by default, such as:\n\\usepackage{setspace}\n\\doublespacing\nThis means that when using theme_tt(\"multipage\") —which does not wrap the table in a table environment— the spacing is not reset, and tables are double spaced. This is not a bug, since double-spacing is in fact what the user requested. Nevertheless, the behavior can seem surprising for those used to the automagical table environment spacing reset.\nOne workaround is to add the following to the document preamble when using multipage/longtblr:\n\\usepackage{etoolbox}\n\\AtBeginEnvironment{longtblr}{\\begin{singlespacing}}\n\\AtEndEnvironment{longtblr}{\\end{singlespacing}}\nExample Quarto doc:\n---\ntitle: longtblr and setspacing\nformat:\n pdf:\n include-in-header:\n - text: |\n % Tinytable preamble\n \\usepackage{tabularray}\n \\usepackage{float}\n \\usepackage{graphicx}\n \\usepackage{codehigh}\n \\usepackage[normalem]{ulem}\n \\UseTblrLibrary{booktabs}\n \\UseTblrLibrary{siunitx}\n \\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline\n {#1}}\n \\newcommand{\\tinytableTabularrayStrikeout}[1]{\\sout{#1}}\n \\NewTableCommand{\\tinytableDefineColor}[3]{\\definecolor{\n #1}{#2}{#3}}\n % Spacing Commands\n \\usepackage{setspace}\n \\doublespacing\n % Fix Spacing in longtblr\n \\usepackage{etoolbox}\n \\AtBeginEnvironment{longtblr}{\\begin{singlespacing}}\n \\AtEndEnvironment{longtblr}{\\end{singlespacing}}\n---\n\n```{=latex}\n\\begin{longtblr}[ %% tabularray outer open\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nfoo & bar & baz \\\\\nfoo & bar & baz \\\\\nfoo & bar & baz \\\\\n\\bottomrule\n\\end{longtblr}\n```\n\n\n\ntabularray allows very powerful styling and themeing options. See the reference manual for more information.\nFor example, you can change the size of footnotes in all tables of a document with:\n---\nformat: \n pdf:\n keep-tex: true\n header-includes: |\n \\SetTblrStyle{foot}{font=\\LARGE}\n---\n\n```{r}\nlibrary(tinytable)\nlibrary(magrittr)\ntt(head(iris), notes = \"Blah blah\")\n```\n\n\n\nDue to a bug in the upstream package rmarkdown, Quarto or Rmarkdown presentations compiled to Beamer cannot include adequate package loading commands in the preamble automatically. This bug prevents tinytable::usepackage_latex() from modifying the preamble. Here’s a workaround.\nSave this LaTeX code as preamble.tex:\n\\RequirePackage{tabularray}\n\\RequirePackage{booktabs}\n\\RequirePackage{float}\n\\usepackage[normalem]{ulem}\n\\usepackage{graphicx}\n\\UseTblrLibrary{booktabs}\n\\UseTblrLibrary{siunitx}\n\\NewTableCommand{\\tinytableDefineColor}[3]{\\definecolor{#1}{#2}{#3}}\n\\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline{#1}}\n\\newcommand{\\tinytableTabularrayStrikeout}[1]{\\sout{#1}}\nThen, load preamble.tex in your YAML header:\n---\noutput: \n beamer_presentation:\n includes:\n in_header: preamble.tex\n---\nWith these changes, the table should appear with colors as expected.\n\n\n\n\n\n\nDue to a quirk in Quarto reported here, captions in Typst and Quarto documents need to be specified using both the tbl-cap and the label chunk option:\n```{r}\n#| tbl-cap: \"blah blah blah\"\n#| label: tbl-blah\ntinytable::tt(head(iris, 5))\n```\n\n\n\nThe Typst tables created by tinytable are automatically broken across pages with repeated headers. However, in Quarto documents, the Quarto software wraps tables in an non-breakable #figure environment. This can break the display of long tables. One solution is to use a raw Typst code block to set Figures to be breakable:\n---\nformat: typst\n---\n\n```{=typst}\n#show figure: set block(breakable: true)\n```\n\n```{r}\n#| tbl-cap: \"blah blah blah\"\n#| label: tbl-blah\nlibrary(tinytable)\ntt(head(iris, 50))\n```\n\n\n\n\n\n\nThis is an important limitation, but it is difficult to get around. See this issue for discussion: https://github.com/vincentarelbundock/tinytable/issues/125\nUsers can use markdown styling directly in group_tt() to circumvent this. This is documented in the tutorial.\n\n\n\nThese arguments are already implemented in the form of “pseudo-spans”, meaning that we flush the content of adjacent cells, but do not modify the row or column borders. This is probably adequate for most needs.\nOne alternative would be to remove line segments in finalize_grid(). I tried this but it is tricky and the results were brittle, so I rolled it back. I’m open to considering a PR if someone wants to contribute code, but please discuss the feature design in an issue with me before working on this.\n\n\n\n\n\n\nIn Quarto, it is possible to create a custom crossref type for things like appendix tables. One challenge, is that LaTeX will not allow users to nest a tblr environment, inside a table environment, inside the new environment that Quarto creates for the crossref. Therefore, when rendering a table to LaTeX/PDF, it is important to drop the \\begin{table} environment. This can be done using the theme_tt() function.\nIn the example below, we call theme_tt() explicitly for a single table, but the themes vignette shows how to set a global theme using the tinytable_tt_theme option.\n---\ntitle: \"Crossref Example\"\nformat:\n pdf: default\n html: default\ncrossref:\n custom:\n - kind: float\n key: apptbl\n latex-env: apptbl\n reference-prefix: Table A\n space-before-numbering: false\n latex-list-of-description: Appendix Table\napptbl-cap-location: top\n---\n\nSee @apptbl-testing\n\n::: {#apptbl-testing}\n\n```{r}\nlibrary(tinytable)\n\ntt(mtcars[1:5,]) |> theme_tt(\"tabular\", style = \"tabularray\")\n```\n\nCaption goes here.\n\n:::\n\n\n\nIn some cases, the user wants to print a single table multiple times with different styles in a single HTML document. This will sometimes cause issues, because the style_tt() function inserts several javascript functions to modify the same table, thus creating conflicts. A simple solution is to change the unique ID of the table object manually.\nConsider this RevalJS slideshow in which we sequentially highlight different rows of the data frame:\n---\nformat: revealjs\n---\n\n## Page 1\n\n```{r}\nlibrary(tinytable)\n\ntab <- tt(head(iris))\ntab\n```\n\n## Page 2\n\n```{r}\ntab@id <- \"table_01\"\ntab |> style_tt(i = 3, background = \"skyblue\")\n```\n\n## Page 3\n\n```{r}\ntab@id <- \"table_02\"\ntab |> style_tt(i = 5, background = \"orange\")\n```", "crumbs": [ "Tutorial (PDF)", "Tutorial", - "Style" + "FAQ" ] }, { - "objectID": "vignettes/style.html#conditional-styling", - "href": "vignettes/style.html#conditional-styling", - "title": "Style", + "objectID": "vignettes/faq.html#html", + "href": "vignettes/faq.html#html", + "title": "FAQ", "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 \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": "Relative widths tables: table-layout: fixed vs auto.", "crumbs": [ "Tutorial (PDF)", "Tutorial", - "Style" + "FAQ" ] }, { - "objectID": "vignettes/style.html#vectorized-styling-heatmaps", - "href": "vignettes/style.html#vectorized-styling-heatmaps", - "title": "Style", + "objectID": "vignettes/faq.html#latex", + "href": "vignettes/faq.html#latex", + "title": "FAQ", "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 \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\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 \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\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 \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": "tinytable uses the tabularray package from your LaTeX distribution to draw tables. tabularray, in turn, provides special tblr, talltblr, and longtblr environments to display tabular data.\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\\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\nSome users have encountered unexpected spacing behavior when generating tables that are not wrapped in a \\begin{table} environment (ex: multipage or raw tblr).\nOne issue stems from the fact that the \\begin{table} environment resets any spacing commands in the preamble or body by default, such as:\n\\usepackage{setspace}\n\\doublespacing\nThis means that when using theme_tt(\"multipage\") —which does not wrap the table in a table environment— the spacing is not reset, and tables are double spaced. This is not a bug, since double-spacing is in fact what the user requested. Nevertheless, the behavior can seem surprising for those used to the automagical table environment spacing reset.\nOne workaround is to add the following to the document preamble when using multipage/longtblr:\n\\usepackage{etoolbox}\n\\AtBeginEnvironment{longtblr}{\\begin{singlespacing}}\n\\AtEndEnvironment{longtblr}{\\end{singlespacing}}\nExample Quarto doc:\n---\ntitle: longtblr and setspacing\nformat:\n pdf:\n include-in-header:\n - text: |\n % Tinytable preamble\n \\usepackage{tabularray}\n \\usepackage{float}\n \\usepackage{graphicx}\n \\usepackage{codehigh}\n \\usepackage[normalem]{ulem}\n \\UseTblrLibrary{booktabs}\n \\UseTblrLibrary{siunitx}\n \\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline\n {#1}}\n \\newcommand{\\tinytableTabularrayStrikeout}[1]{\\sout{#1}}\n \\NewTableCommand{\\tinytableDefineColor}[3]{\\definecolor{\n #1}{#2}{#3}}\n % Spacing Commands\n \\usepackage{setspace}\n \\doublespacing\n % Fix Spacing in longtblr\n \\usepackage{etoolbox}\n \\AtBeginEnvironment{longtblr}{\\begin{singlespacing}}\n \\AtEndEnvironment{longtblr}{\\end{singlespacing}}\n---\n\n```{=latex}\n\\begin{longtblr}[ %% tabularray outer open\n] %% tabularray outer close\n{ %% tabularray inner open\ncolspec={Q[]Q[]Q[]Q[]},\n} %% tabularray inner close\n\\toprule\nfoo & bar & baz \\\\\nfoo & bar & baz \\\\\nfoo & bar & baz \\\\\n\\bottomrule\n\\end{longtblr}\n```\n\n\n\ntabularray allows very powerful styling and themeing options. See the reference manual for more information.\nFor example, you can change the size of footnotes in all tables of a document with:\n---\nformat: \n pdf:\n keep-tex: true\n header-includes: |\n \\SetTblrStyle{foot}{font=\\LARGE}\n---\n\n```{r}\nlibrary(tinytable)\nlibrary(magrittr)\ntt(head(iris), notes = \"Blah blah\")\n```\n\n\n\nDue to a bug in the upstream package rmarkdown, Quarto or Rmarkdown presentations compiled to Beamer cannot include adequate package loading commands in the preamble automatically. This bug prevents tinytable::usepackage_latex() from modifying the preamble. Here’s a workaround.\nSave this LaTeX code as preamble.tex:\n\\RequirePackage{tabularray}\n\\RequirePackage{booktabs}\n\\RequirePackage{float}\n\\usepackage[normalem]{ulem}\n\\usepackage{graphicx}\n\\UseTblrLibrary{booktabs}\n\\UseTblrLibrary{siunitx}\n\\NewTableCommand{\\tinytableDefineColor}[3]{\\definecolor{#1}{#2}{#3}}\n\\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline{#1}}\n\\newcommand{\\tinytableTabularrayStrikeout}[1]{\\sout{#1}}\nThen, load preamble.tex in your YAML header:\n---\noutput: \n beamer_presentation:\n includes:\n in_header: preamble.tex\n---\nWith these changes, the table should appear with colors as expected.", "crumbs": [ "Tutorial (PDF)", "Tutorial", - "Style" + "FAQ" ] }, { - "objectID": "vignettes/style.html#lines-borders", - "href": "vignettes/style.html#lines-borders", - "title": "Style", + "objectID": "vignettes/faq.html#typst", + "href": "vignettes/faq.html#typst", + "title": "FAQ", "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 \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\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 \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\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 \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": "Due to a quirk in Quarto reported here, captions in Typst and Quarto documents need to be specified using both the tbl-cap and the label chunk option:\n```{r}\n#| tbl-cap: \"blah blah blah\"\n#| label: tbl-blah\ntinytable::tt(head(iris, 5))\n```\n\n\n\nThe Typst tables created by tinytable are automatically broken across pages with repeated headers. However, in Quarto documents, the Quarto software wraps tables in an non-breakable #figure environment. This can break the display of long tables. One solution is to use a raw Typst code block to set Figures to be breakable:\n---\nformat: typst\n---\n\n```{=typst}\n#show figure: set block(breakable: true)\n```\n\n```{r}\n#| tbl-cap: \"blah blah blah\"\n#| label: tbl-blah\nlibrary(tinytable)\ntt(head(iris, 50))\n```", "crumbs": [ "Tutorial (PDF)", "Tutorial", - "Style" + "FAQ" ] }, { - "objectID": "vignettes/style.html#cell-padding-height-and-width", - "href": "vignettes/style.html#cell-padding-height-and-width", - "title": "Style", + "objectID": "vignettes/faq.html#markdown", + "href": "vignettes/faq.html#markdown", + "title": "FAQ", "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 bootstrap_css = \"padding-right: .2em; padding-top: 2em;\",\n tabularray_inner = \"rowsep={2em}, colsep = {.2em}\"\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": "This is an important limitation, but it is difficult to get around. See this issue for discussion: https://github.com/vincentarelbundock/tinytable/issues/125\nUsers can use markdown styling directly in group_tt() to circumvent this. This is documented in the tutorial.\n\n\n\nThese arguments are already implemented in the form of “pseudo-spans”, meaning that we flush the content of adjacent cells, but do not modify the row or column borders. This is probably adequate for most needs.\nOne alternative would be to remove line segments in finalize_grid(). I tried this but it is tricky and the results were brittle, so I rolled it back. I’m open to considering a PR if someone wants to contribute code, but please discuss the feature design in an issue with me before working on this.", "crumbs": [ "Tutorial (PDF)", "Tutorial", - "Style" + "FAQ" ] }, { - "objectID": "vignettes/style.html#markdown-and-word", - "href": "vignettes/style.html#markdown-and-word", - "title": "Style", + "objectID": "vignettes/faq.html#quarto", + "href": "vignettes/faq.html#quarto", + "title": "FAQ", "section": "", - "text": "Styling 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": "In Quarto, it is possible to create a custom crossref type for things like appendix tables. One challenge, is that LaTeX will not allow users to nest a tblr environment, inside a table environment, inside the new environment that Quarto creates for the crossref. Therefore, when rendering a table to LaTeX/PDF, it is important to drop the \\begin{table} environment. This can be done using the theme_tt() function.\nIn the example below, we call theme_tt() explicitly for a single table, but the themes vignette shows how to set a global theme using the tinytable_tt_theme option.\n---\ntitle: \"Crossref Example\"\nformat:\n pdf: default\n html: default\ncrossref:\n custom:\n - kind: float\n key: apptbl\n latex-env: apptbl\n reference-prefix: Table A\n space-before-numbering: false\n latex-list-of-description: Appendix Table\napptbl-cap-location: top\n---\n\nSee @apptbl-testing\n\n::: {#apptbl-testing}\n\n```{r}\nlibrary(tinytable)\n\ntt(mtcars[1:5,]) |> theme_tt(\"tabular\", style = \"tabularray\")\n```\n\nCaption goes here.\n\n:::\n\n\n\nIn some cases, the user wants to print a single table multiple times with different styles in a single HTML document. This will sometimes cause issues, because the style_tt() function inserts several javascript functions to modify the same table, thus creating conflicts. A simple solution is to change the unique ID of the table object manually.\nConsider this RevalJS slideshow in which we sequentially highlight different rows of the data frame:\n---\nformat: revealjs\n---\n\n## Page 1\n\n```{r}\nlibrary(tinytable)\n\ntab <- tt(head(iris))\ntab\n```\n\n## Page 2\n\n```{r}\ntab@id <- \"table_01\"\ntab |> style_tt(i = 3, background = \"skyblue\")\n```\n\n## Page 3\n\n```{r}\ntab@id <- \"table_02\"\ntab |> style_tt(i = 5, background = \"orange\")\n```", "crumbs": [ "Tutorial (PDF)", "Tutorial", - "Style" + "FAQ" ] }, + { + "objectID": "vignettes/options.html", + "href": "vignettes/options.html", + "title": "Available Options", + "section": "", + "text": "Options can be set with options() and change the default behavior of tinytable. You can either set them in a script (usually at the top) or via .Rprofile. Note that you want to be cautious with putting things in .Rprofile since they might make results not reproducible (e.g. if you change tinytable_format_digits in .Rprofile, the table will be formatted differently).\n\n\nMost options are function specific and allow you to set default values. These all start with tinytable_X_ where X is tt/format/theme/print. See the corresponding help documentation for the what the argument looks like.\n\n\nSets default values for tt() arguments.\n\ntinytable_tt_digits\ntinytable_tt_caption\ntinytable_tt_notes\ntinytable_tt_width\ntinytable_tt_theme\ntinytable_tt_rownames\n\n\n\n\nSets default formats for different kinds of variables. see format_tt()\n\ntinytable_format_digits\ntinytable_format_num_fmt\ntinytable_format_num_zero\ntinytable_format_num_suffix\ntinytable_format_num_mark_big\ntinytable_format_num_mark_dec\ntinytable_format_date\ntinytable_format_bool\ntinytable_format_other\ntinytable_format_replace\ntinytable_format_escape\ntinytable_format_markdown\ntinytable_format_quarto\ntinytable_format_fn\ntinytable_format_sprintf\n\n\n\n\nWhen using theme_tt(theme = \"theme_name\"), this allows you to set default arguments to the corresponding theme. See theme_tt() for details.\nplacement - tinytable_theme_placement_float - tinytable_theme_placement_horizontal\nresize - tinytable_theme_resize_width - tinytable_theme_resize_direction\nmultipate - tinytable_theme_multipage_rowhead - tinytable_theme_multipage_rowfoot\ntabular - tinytable_theme_tabular_style\n\n\n\ntinytable_print_output\n\n\n\n\nThe rest of the options are a set of global options that apply when the tables are being built.\n\n\n\nEXPERIMENTAL options(tinytable_html_mathjax = TRUE) inserts MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\n\n\n\noptions(tinytable_pdf_clean = TRUE) deletes temporary and log files.\noptions(tinytable_pdf_engine = \"xelatex\"): “xelatex”, “pdflatex”, “lualatex”\n\n\n\n\n\noptions(tinytable_markdown_hlines = TRUE) sets whether gridlines are included in markdown tables. This should be true for docx conversion.\n\n\n\n\nThe format_tt(quarto=TRUE) argument activates Quarto data processing for specific cells. This funcationality comes with a few warnings:\n\nCurrently, Quarto provides a \\QuartoMarkdownBase64{} LaTeX macro, but it does not appear to do anything with it. References and markdown codes may not be processed as expected in LaTeX.\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) disables Quarto processing of cell content.\nSetting 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.\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)\nSee this link for more details: https://quarto.org/docs/authoring/tables.html#disabling-quarto-table-processing" + }, + { + "objectID": "vignettes/options.html#default-values-for-function-arguments", + "href": "vignettes/options.html#default-values-for-function-arguments", + "title": "Available Options", + "section": "", + "text": "Most options are function specific and allow you to set default values. These all start with tinytable_X_ where X is tt/format/theme/print. See the corresponding help documentation for the what the argument looks like.\n\n\nSets default values for tt() arguments.\n\ntinytable_tt_digits\ntinytable_tt_caption\ntinytable_tt_notes\ntinytable_tt_width\ntinytable_tt_theme\ntinytable_tt_rownames\n\n\n\n\nSets default formats for different kinds of variables. see format_tt()\n\ntinytable_format_digits\ntinytable_format_num_fmt\ntinytable_format_num_zero\ntinytable_format_num_suffix\ntinytable_format_num_mark_big\ntinytable_format_num_mark_dec\ntinytable_format_date\ntinytable_format_bool\ntinytable_format_other\ntinytable_format_replace\ntinytable_format_escape\ntinytable_format_markdown\ntinytable_format_quarto\ntinytable_format_fn\ntinytable_format_sprintf\n\n\n\n\nWhen using theme_tt(theme = \"theme_name\"), this allows you to set default arguments to the corresponding theme. See theme_tt() for details.\nplacement - tinytable_theme_placement_float - tinytable_theme_placement_horizontal\nresize - tinytable_theme_resize_width - tinytable_theme_resize_direction\nmultipate - tinytable_theme_multipage_rowhead - tinytable_theme_multipage_rowfoot\ntabular - tinytable_theme_tabular_style\n\n\n\ntinytable_print_output" + }, + { + "objectID": "vignettes/options.html#global-options", + "href": "vignettes/options.html#global-options", + "title": "Available Options", + "section": "", + "text": "The rest of the options are a set of global options that apply when the tables are being built.\n\n\n\nEXPERIMENTAL options(tinytable_html_mathjax = TRUE) inserts MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.\n\n\n\n\n\noptions(tinytable_pdf_clean = TRUE) deletes temporary and log files.\noptions(tinytable_pdf_engine = \"xelatex\"): “xelatex”, “pdflatex”, “lualatex”\n\n\n\n\n\noptions(tinytable_markdown_hlines = TRUE) sets whether gridlines are included in markdown tables. This should be true for docx conversion.\n\n\n\n\nThe format_tt(quarto=TRUE) argument activates Quarto data processing for specific cells. This funcationality comes with a few warnings:\n\nCurrently, Quarto provides a \\QuartoMarkdownBase64{} LaTeX macro, but it does not appear to do anything with it. References and markdown codes may not be processed as expected in LaTeX.\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) disables Quarto processing of cell content.\nSetting 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.\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)\nSee this link for more details: https://quarto.org/docs/authoring/tables.html#disabling-quarto-table-processing" + }, { "objectID": "vignettes/custom.html", "href": "vignettes/custom.html", diff --git a/vignettes/alternatives.html b/vignettes/alternatives.html index a6fc7813..e4de8719 100644 --- a/vignettes/alternatives.html +++ b/vignettes/alternatives.html @@ -125,6 +125,10 @@
  • Customization +
  • +
  • + + Available Options
  • diff --git a/vignettes/custom.html b/vignettes/custom.html index 66a23012..e83c6951 100644 --- a/vignettes/custom.html +++ b/vignettes/custom.html @@ -159,6 +159,10 @@
  • Customization +
  • +
  • + + Available Options
  • @@ -423,12 +427,12 @@

    Bootstrap classes

    -
  • +
    @@ -528,12 +532,12 @@

    Bootstrap classes

    -
    +
    @@ -634,12 +638,12 @@

    Bootstrap classes

    -
    +
    @@ -743,12 +747,12 @@

    CSS declarations

    -
    +
    @@ -894,12 +898,12 @@

    CSS rules

    -
    +
    @@ -1063,12 +1067,12 @@

    CSS rules

    -
    +
    diff --git a/vignettes/faq.html b/vignettes/faq.html index 6dfb0ad8..383f5e19 100644 --- a/vignettes/faq.html +++ b/vignettes/faq.html @@ -159,6 +159,10 @@
  • Customization +
  • +
  • + + Available Options
  • diff --git a/vignettes/format.html b/vignettes/format.html index 22280bdc..38facad0 100644 --- a/vignettes/format.html +++ b/vignettes/format.html @@ -179,6 +179,10 @@
  • Customization +
  • +
  • + + Available Options
  • @@ -441,12 +445,12 @@

    Numbers, dates,
    -

  • +
    @@ -506,19 +510,19 @@

    Numbers, dates,

    - + - + - + @@ -544,12 +548,12 @@

    Numbers, dates,
    -

    143002 1.431971-09-261971-04-23 True
    201399 201.4 1970-03-051971-04-08 True
    100188 0.131970-05-011970-02-22 False
    +
    @@ -609,19 +613,19 @@

    Numbers, dates,

    - + - + - + @@ -644,12 +648,12 @@

    Numbers, dates,
    -

    143 002,21 1.4September 26 1971April 23 1971 True
    201 399,18 201.4March 05 1970April 08 1971 True
    100 188,39 0.1May 01 1970February 22 1970 False
    +
    @@ -756,12 +760,12 @@

    Significan
    -

    +
    @@ -831,12 +835,12 @@

    Significan
    -

    +
    @@ -908,12 +912,12 @@

    Significan
    -

    +
    @@ -988,12 +992,12 @@

    Replacement

    -
    +
    @@ -1068,12 +1072,12 @@

    Replacement

    -
    +
    @@ -1148,12 +1152,12 @@

    Replacement

    -
    +
    @@ -1233,12 +1237,12 @@

    Replacement

    -
    +
    @@ -1332,12 +1336,12 @@

    Escape special c
    -

    +
    @@ -1432,12 +1436,12 @@

    Markdown

    -
    +
    @@ -1540,12 +1544,12 @@

    Markdown

    -
    +

    Vincent sometimes contributes to these R packages.

    @@ -1660,12 +1664,12 @@

    Custom functions

    -

    Vincent sometimes contributes to these R packages.

    +
    @@ -1780,12 +1784,12 @@

    Custom functions

    -
    +
    @@ -1891,12 +1895,12 @@

    Quarto data process
    -

    +
    @@ -1969,12 +1973,12 @@

    Quarto data process
    -

    Thing
    +
    @@ -2050,12 +2054,12 @@

    Quarto data process
    -

    Thing
    +
    diff --git a/vignettes/group.html b/vignettes/group.html index f2c89745..ac2899d6 100644 --- a/vignettes/group.html +++ b/vignettes/group.html @@ -159,6 +159,10 @@
  • Customization +
  • +
  • + + Available Options
  • @@ -416,12 +420,12 @@

    Rows

    -
  • mpg
    +
    @@ -612,12 +616,12 @@

    Rows

    -
    +
    @@ -746,12 +750,12 @@

    Rows

    -
    +
    @@ -879,12 +883,12 @@

    Rows

    -
    +
    @@ -1023,12 +1027,12 @@

    Rows

    -
    +
    @@ -1251,12 +1255,12 @@

    Columns

    -
    +
    @@ -1455,12 +1459,12 @@

    Columns

    -
    Hamburgers
    +
    @@ -1685,12 +1689,12 @@

    Columns

    -
    Hamburgers
    +
    diff --git a/vignettes/options.html b/vignettes/options.html new file mode 100644 index 00000000..f1416348 --- /dev/null +++ b/vignettes/options.html @@ -0,0 +1,919 @@ + + + + + + + + + +options – tinytable + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + +
    + +
    + + +
    + + + +
    + + + + +
    +

    Available Options

    +

    Options can be set with options() and change the default behavior of tinytable. You can either set them in a script (usually at the top) or via .Rprofile. Note that you want to be cautious with putting things in .Rprofile since they might make results not reproducible (e.g. if you change tinytable_format_digits in .Rprofile, the table will be formatted differently).

    +
    +

    Default values for function arguments

    +

    Most options are function specific and allow you to set default values. These all start with tinytable_X_ where X is tt/format/theme/print. See the corresponding help documentation for the what the argument looks like.

    +
    +

    tt()

    +

    Sets default values for tt() arguments.

    +
      +
    • tinytable_tt_digits
    • +
    • tinytable_tt_caption
    • +
    • tinytable_tt_notes
    • +
    • tinytable_tt_width
    • +
    • tinytable_tt_theme
    • +
    • tinytable_tt_rownames
    • +
    +
    +
    +

    format_tt()

    +

    Sets default formats for different kinds of variables. see format_tt()

    +
      +
    • tinytable_format_digits
    • +
    • tinytable_format_num_fmt
    • +
    • tinytable_format_num_zero
    • +
    • tinytable_format_num_suffix
    • +
    • tinytable_format_num_mark_big
    • +
    • tinytable_format_num_mark_dec
    • +
    • tinytable_format_date
    • +
    • tinytable_format_bool
    • +
    • tinytable_format_other
    • +
    • tinytable_format_replace
    • +
    • tinytable_format_escape
    • +
    • tinytable_format_markdown
    • +
    • tinytable_format_quarto
    • +
    • tinytable_format_fn
    • +
    • tinytable_format_sprintf
    • +
    +
    +
    +

    theme_tt()

    +

    When using theme_tt(theme = "theme_name"), this allows you to set default arguments to the corresponding theme. See theme_tt() for details.

    +

    placement - tinytable_theme_placement_float - tinytable_theme_placement_horizontal

    +

    resize - tinytable_theme_resize_width - tinytable_theme_resize_direction

    +

    multipate - tinytable_theme_multipage_rowhead - tinytable_theme_multipage_rowfoot

    +

    tabular - tinytable_theme_tabular_style

    +
    +
    +

    print.tinytable()

    +

    tinytable_print_output

    +
    +
    +
    +

    Global options

    +

    The rest of the options are a set of global options that apply when the tables are being built.

    +
    +

    HTML

    +
      +
    • EXPERIMENTAL options(tinytable_html_mathjax = TRUE) inserts MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.
    • +
    +
    +
    +

    PDF

    +
      +
    • options(tinytable_pdf_clean = TRUE) deletes temporary and log files.
    • +
    • options(tinytable_pdf_engine = "xelatex"): “xelatex”, “pdflatex”, “lualatex”
    • +
    +
    +
    +

    Markdown

    +
      +
    • options(tinytable_markdown_hlines = TRUE) sets whether gridlines are included in markdown tables. This should be true for docx conversion.
    • +
    +
    +
    +

    Quarto

    +

    The format_tt(quarto=TRUE) argument activates Quarto data processing for specific cells. This funcationality comes with a few warnings:

    +
      +
    1. Currently, Quarto provides a \QuartoMarkdownBase64{} LaTeX macro, but it does not appear to do anything with it. References and markdown codes may not be processed as expected in LaTeX.
    2. +
    3. Quarto data processing can enter in conflict with tinytable styling or formatting options. See below for how to disable it.
    4. +
    +
      +
    • options(tinytable_quarto_disable_processing = TRUE) disables 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.

      +
      x <- data.frame(Math = "x^2^", Citation = "@Lovelace1842")
      +fn <- function(z) sprintf("<span data-qmd='%s'></span>", z)
      +tt(x) |> format_tt(i = 1, fn = fn)
      +

      See this link for more details: https://quarto.org/docs/authoring/tables.html#disabling-quarto-table-processing

    • +
    + + +
    +
    +
    + +
    + +
    + + + + + \ No newline at end of file diff --git a/vignettes/plot.html b/vignettes/plot.html index f456bac9..5fee05f5 100644 --- a/vignettes/plot.html +++ b/vignettes/plot.html @@ -159,6 +159,10 @@
  • Customization +
  • +
  • + + Available Options
  • @@ -427,12 +431,12 @@

    Inserting image
    -

  • Hello
    +
    @@ -510,12 +514,12 @@

    Inserting image
    -

    +
    @@ -614,12 +618,12 @@

    Built-in plots

    -
    +
    @@ -694,24 +698,24 @@

    Built-in plots

    - - - - + + + + - - - - + + + + - - - - + + + +
    mpg
    hp
    qsec
    @@ -740,12 +744,12 @@

    Custom plots: Base
    - +
    @@ -800,15 +804,15 @@

    Custom plots: Base

    - + - + - +
    mpg
    hp
    qsec
    @@ -841,12 +845,12 @@

    Custom plots: g
    - +
    @@ -901,15 +905,15 @@

    Custom plots: g

    - + - + - +
    mpg
    hp
    qsec
    @@ -958,12 +962,12 @@

    Custom plots: g
    - +
    @@ -1033,21 +1037,21 @@

    Custom plots: g

    - - - + + + - - - + + + - - - + + +
    Adelie
    Chinstrap
    Gentoo
    @@ -1069,12 +1073,12 @@

    Fontawesome

    - +
    diff --git a/vignettes/style.html b/vignettes/style.html index f43c4f52..cf34a3da 100644 --- a/vignettes/style.html +++ b/vignettes/style.html @@ -159,6 +159,10 @@
  • Customization +
  • +
  • + + Available Options
  • @@ -445,12 +449,12 @@

    Cells, rows, columns
    -

  • +
    @@ -557,12 +561,12 @@

    Cells, rows, columns
    -

    +
    @@ -669,12 +673,12 @@

    Cells, rows, columns
    -

    +
    @@ -795,12 +799,12 @@

    Cells, rows, columns
    -

    +
    @@ -911,12 +915,12 @@

    Cells, rows, columns
    -

    +
    @@ -1026,12 +1030,12 @@

    Cells, rows, columns
    -

    +
    @@ -1138,12 +1142,12 @@

    Cells, rows, columns
    -

    +
    @@ -1253,12 +1257,12 @@

    Cells, rows, columns
    -

    +
    @@ -1374,12 +1378,12 @@

    Cells, rows, columns
    -

    +
    @@ -1501,12 +1505,12 @@

    Colors

    -
    +
    @@ -1620,12 +1624,12 @@

    Alignment

    -
    +
    @@ -1715,12 +1719,12 @@

    Alignment

    -
    +
    @@ -1820,12 +1824,12 @@

    Alignment

    -
    +
    @@ -1909,12 +1913,12 @@

    Font size

    -
    +
    @@ -2035,12 +2039,12 @@

    Spanning cell
    -

    +
    @@ -2143,12 +2147,12 @@

    Spanning cell
    -

    +
    @@ -2261,12 +2265,12 @@

    Spanning cell
    -

    +
    @@ -2374,12 +2378,12 @@

    Spanning cell
    -

    +
    @@ -2455,12 +2459,12 @@

    Spanning cell
    -

    +
    @@ -2540,12 +2544,12 @@

    Headers

    -
    +
    @@ -2638,12 +2642,12 @@

    Headers

    -
    +
    @@ -2743,12 +2747,12 @@

    Headers

    -
    +
    @@ -2867,12 +2871,12 @@

    Conditional styling
    -

    +
    @@ -3006,12 +3010,12 @@

    Vectorized sty
    -

    +
    @@ -3139,12 +3143,12 @@

    Vectorized sty
    -

    +
    @@ -3275,12 +3279,12 @@

    Vectorized sty
    -

    +
    @@ -3429,12 +3433,12 @@

    Lines (borders)

    -
    +
    @@ -3544,12 +3548,12 @@

    Lines (borders)

    -
    +
    @@ -3660,12 +3664,12 @@

    Lines (borders)

    -
    +
    @@ -3751,12 +3755,12 @@

    Cell padding
    -

    +
    diff --git a/vignettes/theme.html b/vignettes/theme.html index 5424a87c..e8f7b999 100644 --- a/vignettes/theme.html +++ b/vignettes/theme.html @@ -159,6 +159,10 @@
  • Customization +
  • +
  • + + Available Options
  • @@ -415,12 +419,12 @@

    Visual themes

    -
  • +
    @@ -615,12 +619,12 @@

    Visual themes

    -
    +
    @@ -907,12 +911,12 @@

    Custom themes

    -
    Always use the same caption.
    +
    diff --git a/vignettes/tinytable.html b/vignettes/tinytable.html index 51342c55..e1081556 100644 --- a/vignettes/tinytable.html +++ b/vignettes/tinytable.html @@ -158,6 +158,10 @@
  • Customization +
  • +
  • + + Available Options
  • @@ -419,12 +423,12 @@

    Tiny Tables

    -
  • Always use the same caption.
    +
    @@ -526,12 +530,12 @@

    Width

    -
    +
    @@ -630,12 +634,12 @@

    Width

    -
    +
    @@ -735,12 +739,12 @@

    Width

    -
    +
    @@ -863,12 +867,12 @@

    Width

    -
    +
    @@ -998,12 +1002,12 @@

    Width

    -
    +
    @@ -1078,12 +1082,12 @@

    Footnotes

    -
    +

    A full-width table with wrapped text in cells and a footnote.

    @@ -1156,12 +1160,12 @@

    Footnotes

    -

    A full-width table with wrapped text in cells and a footnote.

    +
    @@ -1272,12 +1276,12 @@

    Footnotes

    -
    +
    @@ -1404,12 +1408,12 @@

    Captions and
    -

    +
    @@ -1541,12 +1545,12 @@

    Math

    -
    +
    @@ -1626,12 +1630,12 @@

    Line breaks
    -

    +
    @@ -1780,12 +1784,12 @@

    Combination an
    -

    +
    @@ -1876,12 +1880,12 @@

    Combination an
    -

    +
    @@ -1958,12 +1962,12 @@

    Combination an
    -

    +
    @@ -2074,12 +2078,12 @@

    Combination an
    -

    Combine two tiny tables.
    +
    @@ -2194,12 +2198,12 @@

    Combination an
    -

    Combine two tiny tables.
    +
    @@ -2306,12 +2310,12 @@

    Combination an
    -

    Combine two tiny tables.
    +
    diff --git a/vignettes/tinytable_assets/id1vd5n400pbpw7swq19q8.png b/vignettes/tinytable_assets/id1vd5n400pbpw7swq19q8.png new file mode 100644 index 00000000..b2a2c40c Binary files /dev/null and b/vignettes/tinytable_assets/id1vd5n400pbpw7swq19q8.png differ diff --git a/vignettes/tinytable_assets/id28qzguogeqfrqo13mmb6.png b/vignettes/tinytable_assets/id28qzguogeqfrqo13mmb6.png new file mode 100644 index 00000000..f4e677bc Binary files /dev/null and b/vignettes/tinytable_assets/id28qzguogeqfrqo13mmb6.png differ diff --git a/vignettes/tinytable_assets/id2odad9x0m441wgi8y7ya.png b/vignettes/tinytable_assets/id2odad9x0m441wgi8y7ya.png new file mode 100644 index 00000000..5e2927f9 Binary files /dev/null and b/vignettes/tinytable_assets/id2odad9x0m441wgi8y7ya.png differ diff --git a/vignettes/tinytable_assets/id3mzns7hsdhem31vxp2np.png b/vignettes/tinytable_assets/id3mzns7hsdhem31vxp2np.png new file mode 100644 index 00000000..8ec24e8d Binary files /dev/null and b/vignettes/tinytable_assets/id3mzns7hsdhem31vxp2np.png differ diff --git a/vignettes/tinytable_assets/id4073pxmu00cttob5azdx.png b/vignettes/tinytable_assets/id4073pxmu00cttob5azdx.png new file mode 100644 index 00000000..04b900e8 Binary files /dev/null and b/vignettes/tinytable_assets/id4073pxmu00cttob5azdx.png differ diff --git a/vignettes/tinytable_assets/id54s638m6j2izzbeetz1k.png b/vignettes/tinytable_assets/id54s638m6j2izzbeetz1k.png new file mode 100644 index 00000000..45c6479e Binary files /dev/null and b/vignettes/tinytable_assets/id54s638m6j2izzbeetz1k.png differ diff --git a/vignettes/tinytable_assets/id5b43tvoksxmk3p8ghbh1.png b/vignettes/tinytable_assets/id5b43tvoksxmk3p8ghbh1.png new file mode 100644 index 00000000..0981e71f Binary files /dev/null and b/vignettes/tinytable_assets/id5b43tvoksxmk3p8ghbh1.png differ diff --git a/vignettes/tinytable_assets/id71bqq7fr9qmbc56bn2z1.png b/vignettes/tinytable_assets/id71bqq7fr9qmbc56bn2z1.png new file mode 100644 index 00000000..213bef86 Binary files /dev/null and b/vignettes/tinytable_assets/id71bqq7fr9qmbc56bn2z1.png differ diff --git a/vignettes/tinytable_assets/idaakpsqcyxgifo1pqu4js.png b/vignettes/tinytable_assets/idaakpsqcyxgifo1pqu4js.png new file mode 100644 index 00000000..d7222e0f Binary files /dev/null and b/vignettes/tinytable_assets/idaakpsqcyxgifo1pqu4js.png differ diff --git a/vignettes/tinytable_assets/idb71uv0z5as05zllr882c.png b/vignettes/tinytable_assets/idb71uv0z5as05zllr882c.png new file mode 100644 index 00000000..5f1e6473 Binary files /dev/null and b/vignettes/tinytable_assets/idb71uv0z5as05zllr882c.png differ diff --git a/vignettes/tinytable_assets/idc6jly4et84ei9m31xlh7.png b/vignettes/tinytable_assets/idc6jly4et84ei9m31xlh7.png new file mode 100644 index 00000000..b6cc9f62 Binary files /dev/null and b/vignettes/tinytable_assets/idc6jly4et84ei9m31xlh7.png differ diff --git a/vignettes/tinytable_assets/idei2vs19t90tji6p92m26.png b/vignettes/tinytable_assets/idei2vs19t90tji6p92m26.png new file mode 100644 index 00000000..3ce82825 Binary files /dev/null and b/vignettes/tinytable_assets/idei2vs19t90tji6p92m26.png differ diff --git a/vignettes/tinytable_assets/idg06zn6yqbl8rhsmcqlgs.png b/vignettes/tinytable_assets/idg06zn6yqbl8rhsmcqlgs.png new file mode 100644 index 00000000..1cfe3c01 Binary files /dev/null and b/vignettes/tinytable_assets/idg06zn6yqbl8rhsmcqlgs.png differ diff --git a/vignettes/tinytable_assets/idgfv4gy7ktj6vmgsaecg9.png b/vignettes/tinytable_assets/idgfv4gy7ktj6vmgsaecg9.png new file mode 100644 index 00000000..4e1ff0a7 Binary files /dev/null and b/vignettes/tinytable_assets/idgfv4gy7ktj6vmgsaecg9.png differ diff --git a/vignettes/tinytable_assets/idi1m0katvolw0onygqh2i.png b/vignettes/tinytable_assets/idi1m0katvolw0onygqh2i.png new file mode 100644 index 00000000..0ba387fc Binary files /dev/null and b/vignettes/tinytable_assets/idi1m0katvolw0onygqh2i.png differ diff --git a/vignettes/tinytable_assets/idjobrryk0fq0ga2bn0c6r.png b/vignettes/tinytable_assets/idjobrryk0fq0ga2bn0c6r.png new file mode 100644 index 00000000..ebf19a52 Binary files /dev/null and b/vignettes/tinytable_assets/idjobrryk0fq0ga2bn0c6r.png differ diff --git a/vignettes/tinytable_assets/idk4hg078z50ji58qvl31s.png b/vignettes/tinytable_assets/idk4hg078z50ji58qvl31s.png new file mode 100644 index 00000000..fa8a2afc Binary files /dev/null and b/vignettes/tinytable_assets/idk4hg078z50ji58qvl31s.png differ diff --git a/vignettes/tinytable_assets/idmeoxz25xv1knrflj0fsr.png b/vignettes/tinytable_assets/idmeoxz25xv1knrflj0fsr.png new file mode 100644 index 00000000..51ac33e1 Binary files /dev/null and b/vignettes/tinytable_assets/idmeoxz25xv1knrflj0fsr.png differ diff --git a/vignettes/tinytable_assets/idmz095fqcu8tfjzixo939.png b/vignettes/tinytable_assets/idmz095fqcu8tfjzixo939.png new file mode 100644 index 00000000..e677d3ef Binary files /dev/null and b/vignettes/tinytable_assets/idmz095fqcu8tfjzixo939.png differ diff --git a/vignettes/tinytable_assets/idouw2tyxuu01ii8t0llse.png b/vignettes/tinytable_assets/idouw2tyxuu01ii8t0llse.png new file mode 100644 index 00000000..5e33c88b Binary files /dev/null and b/vignettes/tinytable_assets/idouw2tyxuu01ii8t0llse.png differ diff --git a/vignettes/tinytable_assets/idpqagl2swsvucbmy4678y.png b/vignettes/tinytable_assets/idpqagl2swsvucbmy4678y.png new file mode 100644 index 00000000..79d2ec07 Binary files /dev/null and b/vignettes/tinytable_assets/idpqagl2swsvucbmy4678y.png differ diff --git a/vignettes/tinytable_assets/idq6291p9azltgdi6xt4b9.png b/vignettes/tinytable_assets/idq6291p9azltgdi6xt4b9.png new file mode 100644 index 00000000..8eaafeb9 Binary files /dev/null and b/vignettes/tinytable_assets/idq6291p9azltgdi6xt4b9.png differ diff --git a/vignettes/tinytable_assets/ids0765u8e42ml1aj2gag7.png b/vignettes/tinytable_assets/ids0765u8e42ml1aj2gag7.png new file mode 100644 index 00000000..82861ab5 Binary files /dev/null and b/vignettes/tinytable_assets/ids0765u8e42ml1aj2gag7.png differ diff --git a/vignettes/tinytable_assets/ids7kytldjatqhbqqxzwq4.png b/vignettes/tinytable_assets/ids7kytldjatqhbqqxzwq4.png new file mode 100644 index 00000000..0e9656bb Binary files /dev/null and b/vignettes/tinytable_assets/ids7kytldjatqhbqqxzwq4.png differ diff --git a/vignettes/tinytable_assets/iduss0pq6nzkl1dop34g5k.png b/vignettes/tinytable_assets/iduss0pq6nzkl1dop34g5k.png new file mode 100644 index 00000000..e0b2cddc Binary files /dev/null and b/vignettes/tinytable_assets/iduss0pq6nzkl1dop34g5k.png differ diff --git a/vignettes/tinytable_assets/idw3rphdn9r9ccf41hcx4f.png b/vignettes/tinytable_assets/idw3rphdn9r9ccf41hcx4f.png new file mode 100644 index 00000000..80279d32 Binary files /dev/null and b/vignettes/tinytable_assets/idw3rphdn9r9ccf41hcx4f.png differ diff --git a/vignettes/tinytable_assets/idxes4u4mwmyn212gnaqcw.png b/vignettes/tinytable_assets/idxes4u4mwmyn212gnaqcw.png new file mode 100644 index 00000000..cba1148d Binary files /dev/null and b/vignettes/tinytable_assets/idxes4u4mwmyn212gnaqcw.png differ diff --git a/vignettes/tinytable_tutorial.pdf b/vignettes/tinytable_tutorial.pdf index 0776581b..3597b317 100644 Binary files a/vignettes/tinytable_tutorial.pdf and b/vignettes/tinytable_tutorial.pdf differ
    Combine two tiny tables.