From b769aab481d116181d14448977986c78cd017544 Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Sun, 28 Jan 2024 21:27:33 -0500 Subject: [PATCH] docs --- R/group_tt.R | 12 ++++++++++++ R/style_tt.R | 6 +++--- man/group_tt.Rd | 15 +++++++++++++-- man/style_tt.Rd | 8 ++++---- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/R/group_tt.R b/R/group_tt.R index 7a1c92a8..c2d8cf32 100644 --- a/R/group_tt.R +++ b/R/group_tt.R @@ -3,8 +3,20 @@ #' @export #' @inheritParams tt #' @inheritParams style_tt +#' @param i A named list of row indices to group. The names of the list will be used as labels. +#' @param j A named list of column indices to group. The names of the list will be used as labels. See examples below.. #' @return An object of class `tt` representing the table. #' @param indent integer number of `pt` to use when indenting the non-labelled rows. +#' @examples +#' +#' tt(mtcars[1:10, 1:5]) |> +#' group_tt( +#' i = list( +#' "Hello" = 3, +#' "World" = 8), +#' j = list( +#' "Foo" = 2:3, +#' "Bar" = 4:5)) group_tt <- function(x, i = NULL, j = NULL, indent = 1) { if (is.null(meta(x))) stop("`x` must be generated by `tinytable::tt()`.", call. = FALSE) diff --git a/R/style_tt.R b/R/style_tt.R index b7ba04c0..53d109ef 100644 --- a/R/style_tt.R +++ b/R/style_tt.R @@ -1,9 +1,9 @@ -#' Style a Tiny Table in either LaTeX or HTML format +#' Style a Tiny Table #' #' @details -#' This 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 supports both LaTeX (tabularray) and HTML (bootstrap) formats. +#' This 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. #' -#' Note that Markdown and Word formats are limited to these styles: italic, bold, strikeout. +#' Warning: Markdown and Word formats are limited to these styles: italic, bold, strikeout. This is because there is no markdown syntax for the other options, and because we create Word documents by converting a markdown table to .docx via the Pandoc software. #' #' @param x A table object created by `tt()`. #' @param i Row 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. diff --git a/man/group_tt.Rd b/man/group_tt.Rd index fc252775..0d092a58 100644 --- a/man/group_tt.Rd +++ b/man/group_tt.Rd @@ -9,9 +9,9 @@ group_tt(x, i = NULL, j = NULL, indent = 1) \arguments{ \item{x}{A data frame or data table to be rendered as a table.} -\item{i}{Row indices where the styling should be applied. Can be a single value or a vector. \code{i=0} is the header, and negative values are higher level headers. If \code{colspan} is used, \code{i} must be of length 1.} +\item{i}{A named list of row indices to group. The names of the list will be used as labels.} -\item{j}{Column indices where the styling should be applied. Can be a single value, a vector, or a Perl-style regular expression applied to column names of the original data frame. If \code{colspan} is used, \code{j} must be of length 1.} +\item{j}{A named list of column indices to group. The names of the list will be used as labels. See examples below..} \item{indent}{integer number of \code{pt} to use when indenting the non-labelled rows.} } @@ -21,3 +21,14 @@ An object of class \code{tt} representing the table. \description{ Spanning labels to identify groups of rows or columns } +\examples{ + +tt(mtcars[1:10, 1:5]) |> + group_tt( + i = list( + "Hello" = 3, + "World" = 8), + j = list( + "Foo" = 2:3, + "Bar" = 4:5)) +} diff --git a/man/style_tt.Rd b/man/style_tt.Rd index b4b8fe62..456d091c 100644 --- a/man/style_tt.Rd +++ b/man/style_tt.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/style_tt.R \name{style_tt} \alias{style_tt} -\title{Style a Tiny Table in either LaTeX or HTML format} +\title{Style a Tiny Table} \usage{ style_tt( x, @@ -105,12 +105,12 @@ style_tt( An object of class \code{tt} representing the table. } \description{ -Style a Tiny Table in either LaTeX or HTML format +Style a Tiny Table } \details{ -This function applies styling to a table created by \code{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 supports both LaTeX (tabularray) and HTML (bootstrap) formats. +This function applies styling to a table created by \code{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. -Note that Markdown and Word formats are limited to these styles: italic, bold, strikeout. +Warning: Markdown and Word formats are limited to these styles: italic, bold, strikeout. This is because there is no markdown syntax for the other options, and because we create Word documents by converting a markdown table to .docx via the Pandoc software. } \section{LaTeX preamble}{