From c9d2b24e72a033e4eedc5893a68c96debecf7dc9 Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Fri, 19 Jan 2024 09:49:55 -0500 Subject: [PATCH] docs --- R/group_tt.R | 1 + R/save_tt.R | 9 +++------ R/style_tt.R | 2 +- R/tt.R | 9 ++++----- man/group_tt.Rd | 3 +++ man/save_tt.Rd | 9 +++------ man/style_tt.Rd | 2 +- man/tt.Rd | 8 +++----- 8 files changed, 19 insertions(+), 24 deletions(-) diff --git a/R/group_tt.R b/R/group_tt.R index e0d27e5d..7a1c92a8 100644 --- a/R/group_tt.R +++ b/R/group_tt.R @@ -3,6 +3,7 @@ #' @export #' @inheritParams tt #' @inheritParams style_tt +#' @return An object of class `tt` representing the table. #' @param indent integer number of `pt` to use when indenting the non-labelled rows. group_tt <- function(x, i = NULL, j = NULL, indent = 1) { diff --git a/R/save_tt.R b/R/save_tt.R index 92cea4d2..6ad403d7 100644 --- a/R/save_tt.R +++ b/R/save_tt.R @@ -7,16 +7,13 @@ #' + If `output` is "markdown", "latex", or "html", the table is returned in a string as an `R` object. #' + If `output` is a valid file path, the table is saved to file. The supported extensions are: .html, .png, .pdf, .tex and .md (with aliases .txt, .Rmd and .qmd). #' @param overwrite A logical value indicating whether to overwrite an existing file. -#' @return invisible(TRUE) +#' @return A string or `TRUE` when the table is written to file. #' @export #' @examples -#' \dontrun{ #' #' library(tinytable) -#' tab <- tt(mtcars[1:4, 1:4]) -#' save_tt(tt, "path/to/file.txt") -#' -#' } +#' filename <- file.path(tempfile(), "table.tex") +#' tt(mtcars[1:4, 1:4]) |> save_tt(filename) #' save_tt <- function(x, output, overwrite = FALSE) { m <- meta(x) diff --git a/R/style_tt.R b/R/style_tt.R index 72921377..93dc35d0 100644 --- a/R/style_tt.R +++ b/R/style_tt.R @@ -31,7 +31,7 @@ #' @param tabularray_inner A string that specifies the "inner" settings of a tabularray LaTeX table. #' @param tabularray_outer A string that specifies the "outer" settings of a tabularray LaTeX table. #' @param ... extra arguments are ignored -#' @return Returns a modified `tinytable` object with the applied styles. +#' @return An object of class `tt` representing the table. #' @template latex_preamble #' @export #' @examples diff --git a/R/tt.R b/R/tt.R index e17ba1f2..d340264e 100644 --- a/R/tt.R +++ b/R/tt.R @@ -22,7 +22,6 @@ #' @return An object of class `tt` representing the table. #' @template latex_preamble #' -#' @examplesIf getOption("tt_local", default = FALSE) #' @examples #' library(tinytable) #' x <- mtcars[1:4, 1:5] @@ -30,10 +29,10 @@ #' tt(x) #' #' tt(x, -#' theme = "striped", -#' width = 0.5, -#' caption = "Data about cars.") -#' +#' theme = "striped", +#' width = 0.5, +#' caption = "Data about cars.") +#' #' @export tt <- function(x, digits = NULL, diff --git a/man/group_tt.Rd b/man/group_tt.Rd index 79561cf9..967aa3a4 100644 --- a/man/group_tt.Rd +++ b/man/group_tt.Rd @@ -15,6 +15,9 @@ group_tt(x, i = NULL, j = NULL, indent = 1) \item{indent}{integer number of \code{pt} to use when indenting the non-labelled rows.} } +\value{ +An object of class \code{tt} representing the table. +} \description{ Spanning labels to identify groups of rows or columns } diff --git a/man/save_tt.Rd b/man/save_tt.Rd index e470e2c5..f28aaf0f 100644 --- a/man/save_tt.Rd +++ b/man/save_tt.Rd @@ -18,18 +18,15 @@ save_tt(x, output, overwrite = FALSE) \item{overwrite}{A logical value indicating whether to overwrite an existing file.} } \value{ -invisible(TRUE) +A string or \code{TRUE} when the table is written to file. } \description{ This function saves an object of class tinytable to a specified file and format, with an option to overwrite existing files. } \examples{ -\dontrun{ library(tinytable) -tab <- tt(mtcars[1:4, 1:4]) -save_tt(tt, "path/to/file.txt") - -} +filename <- file.path(tempfile(), "table.tex") +tt(mtcars[1:4, 1:4]) |> save_tt(filename) } diff --git a/man/style_tt.Rd b/man/style_tt.Rd index 6fa4081d..fb00de62 100644 --- a/man/style_tt.Rd +++ b/man/style_tt.Rd @@ -83,7 +83,7 @@ style_tt( \item{...}{extra arguments are ignored} } \value{ -Returns a modified \code{tinytable} object with the applied styles. +An object of class \code{tt} representing the table. } \description{ 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. diff --git a/man/tt.Rd b/man/tt.Rd index a66481d3..78c9c949 100644 --- a/man/tt.Rd +++ b/man/tt.Rd @@ -63,16 +63,14 @@ When rendering Quarto and Rmarkdown documents, \code{tinytable} will populate th } \examples{ -\dontshow{if (getOption("tt_local", default = FALSE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -\dontshow{\}) # examplesIf} library(tinytable) x <- mtcars[1:4, 1:5] tt(x) tt(x, - theme = "striped", - width = 0.5, - caption = "Data about cars.") + theme = "striped", + width = 0.5, + caption = "Data about cars.") }