diff --git a/DESCRIPTION b/DESCRIPTION index b2b0eeafe..9c57371a4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,7 +9,7 @@ Description: Create beautiful and customizable tables to summarize several RTF, JPG, or PNG. Tables can easily be embedded in 'Rmarkdown' or 'knitr' dynamic documents. Details can be found in Arel-Bundock (2022) . -Version: 1.4.5 +Version: 1.9.9.9999 Authors@R: c(person("Vincent", "Arel-Bundock", email = "vincent.arel-bundock@umontreal.ca", role = c("aut", "cre"), @@ -52,12 +52,11 @@ Imports: data.table, generics, glue, - kableExtra (>= 1.3.4), insight (>= 0.19.6), parameters (>= 0.21.2), performance (>= 0.10.5), tables (>= 0.9.17), - tinytable (>= 0.0.4) + tinytable (>= 0.0.5) Suggests: AER, altdoc, @@ -88,6 +87,7 @@ Suggests: huxtable, IRdisplay, ivreg, + kableExtra, knitr, lavaan, lfe, diff --git a/Makefile b/Makefile index 440b4182a..8b505ad56 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ install: document ## devtools::install() deploy: ## pkgdown::deploy_to_branch() Rscript -e "pkgdown::deploy_to_branch()" -document: install ## devtools::document() +document: ## devtools::document() Rscript -e "devtools::document()" website: document ## render vignettes and website diff --git a/NEWS.md b/NEWS.md index 73a39e983..9847129df 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,20 @@ # News +## 1.9.9.9999 + +BREAKING CHANGE: The default output format is now `tinytable` instead of `kableExtra`. Learn more about `tinytable` here: + +https://vincentarelbundock.github.io/tinytable/ + +To revert to the previous behavior persistently, users can call: + +library(modelsummary) +config_modelsummary(factory_default = "kableExtra") + +Other breaking changes: + +* The `statistic_override` argument was replaced by `vcov` over 1 year ago, with appropriate deprecation warnings. It is now fully removed. + ## 1.4.5 * `tinytable` supports histograms in `datasummary_skim()` diff --git a/R/config_modelsummary.R b/R/config_modelsummary.R index c711ff49f..0243efa9b 100644 --- a/R/config_modelsummary.R +++ b/R/config_modelsummary.R @@ -1,6 +1,6 @@ #' Persistent user settings for the `modelsummary` package #' -#' @param factory_default Default output format: "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" +#' @param factory_default Default output format: "tinytable", "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" #' @param factory_latex Name of package used to generate LaTeX output when `output="latex"`. #' @param factory_markdown Name of package used to generate LaTeX output when `output="markdown"`. #' @param factory_html Name of package used to generate LaTeX output when `output="html"`. diff --git a/R/datasummary.R b/R/datasummary.R index 4050510f3..b76375657 100644 --- a/R/datasummary.R +++ b/R/datasummary.R @@ -37,7 +37,7 @@ #' `x~mean*z` will print the `mean`-related header above the `z`-related #' header.` #' @param ... all other arguments are passed through to the table-making -#' functions [kableExtra::kbl], [gt::gt], [DT::datatable], etc. depending on the `output` argument. +#' functions [tinytable::tt], [kableExtra::kbl], [gt::gt], [DT::datatable], etc. depending on the `output` argument. #' This allows users to pass arguments directly to `datasummary` in order to #' affect the behavior of other functions behind the scenes. #' @template citation @@ -124,6 +124,7 @@ #' #datasummary(f, data = mtcars, output = 'latex') #' #' # Return a table object to customize using a table-making package +#' #datasummary(f, data = mtcars, output = 'tinytable') #' #datasummary(f, data = mtcars, output = 'gt') #' #datasummary(f, data = mtcars, output = 'kableExtra') #' #datasummary(f, data = mtcars, output = 'flextable') @@ -144,7 +145,7 @@ #' found in the 'tables' package documentation: ?tables::tabular #' #' Hierarchical or "nested" column labels are only available for these output -#' formats: kableExtra, gt, html, rtf, and LaTeX. When saving tables to other +#' formats: tinytable, kableExtra, gt, html, rtf, and LaTeX. When saving tables to other #' formats, nested labels will be combined to a "flat" header. #' @export datasummary <- function(formula, @@ -222,13 +223,6 @@ datasummary <- function(formula, } } - ## escape stub - sw <- attr(dse, "stub_width") - for (i in 1:sw) { - dse[, i] <- escape_string(dse[, i]) - } - colnames(dse)[1:sw] <- escape_string(colnames(dse)[1:sw]) - # build out <- factory(dse, align = align, @@ -239,6 +233,7 @@ datasummary <- function(formula, title = title, add_columns = add_columns, add_rows = add_rows, + escape = escape, ...) # invisible return diff --git a/R/datasummary_balance.R b/R/datasummary_balance.R index 6f34c0199..02aef00e8 100644 --- a/R/datasummary_balance.R +++ b/R/datasummary_balance.R @@ -258,13 +258,6 @@ datasummary_balance <- function(formula, strrep("r", ncol(tab) - attr(tab, "stub_width"))) } - ## escape stub: re-sanitize because we called `datasummary()` a few times - sanitize_output(output) # before sanitize_escape - sanitize_escape(escape) # after sanitize_output - for (i in 1:attr(tab, "stub_width")) { - tab[[i]] <- escape_string(tab[[i]]) - } - ## weights warning if (isTRUE(any_factor) && "weights" %in% colnames(data)) { msg <- 'When the `data` used in `datasummary_balance` contains a "weights" column, the means, standard deviations, difference in means, and standard errors of numeric variables are adjusted to account for weights. However, the counts and percentages for categorical variables are not adjusted.' @@ -339,7 +332,6 @@ DinM <- function(lhs, rhs, data, fmt, statistic, stars = TRUE, escape = TRUE) { if (identical(statistic, "p.value")) { out[[statistic]] <- rounding(out[[statistic]], pval = TRUE) - out[[statistic]] <- escape_string(out[[statistic]]) # <0.001 interpreted as html tag } else { out[[statistic]] <- rounding(out[[statistic]]) } diff --git a/R/datasummary_correlation.R b/R/datasummary_correlation.R index b7c44d917..b2334c423 100644 --- a/R/datasummary_correlation.R +++ b/R/datasummary_correlation.R @@ -184,9 +184,6 @@ datasummary_correlation <- function(data, align <- paste0('l', strrep('r', ncols - 1)) } - out[, 1] <- escape_string(out[, 1]) - colnames(out) <- escape_string(colnames(out)) - # labelled data dict <- get_variable_labels_data(data) out[, 1] <- replace_dict(out[, 1], dict) diff --git a/R/datasummary_df.R b/R/datasummary_df.R index 4ea541d35..4b7eab4f7 100644 --- a/R/datasummary_df.R +++ b/R/datasummary_df.R @@ -22,9 +22,6 @@ datasummary_df <- function(data, checkmate::assert_data_frame(data) - notes <- escape_string(notes) - title <- escape_string(title) - for (n in colnames(data)) { fmt <- sanitize_fmt(fmt) data[[n]] <- fmt(data[[n]]) diff --git a/R/datasummary_extract.R b/R/datasummary_extract.R index 6fde123a7..3dbe6bed4 100644 --- a/R/datasummary_extract.R +++ b/R/datasummary_extract.R @@ -65,9 +65,6 @@ datasummary_extract <- function(tab, # stub_width attribute before return attr(main, 'stub_width') <- stub_width - # escape latex column names - colnames(main) <- escape_string(colnames(main)) - # 1 header level means colnames are sufficient. return output immediately. # this needs to go before definition of header_nocolnames if (nrow(header) == 1) { diff --git a/R/datasummary_skim.R b/R/datasummary_skim.R index 23e0b642e..a4c58fe95 100644 --- a/R/datasummary_skim.R +++ b/R/datasummary_skim.R @@ -11,7 +11,7 @@ #' @param histogram include a histogram (TRUE/FALSE). Supported for: #' \itemize{ #' \item type = "numeric" -#' \item output is "html", "default", "jpg", "png", or "kableExtra" +#' \item output is "html", "default", "jpg", "png", "tinytable", or "kableExtra" #' \item PDF and HTML documents compiled via Rmarkdown or knitr #' \item See the examples section below for an example of how to use #' `datasummary` to include histograms in other formats such as markdown. diff --git a/R/factory_kableExtra.R b/R/factory_kableExtra.R index 8cc2984ec..5e825b85b 100644 --- a/R/factory_kableExtra.R +++ b/R/factory_kableExtra.R @@ -15,6 +15,24 @@ factory_kableExtra <- function(tab, insight::check_if_installed("kableExtra") + output_format <- settings_get("output_format") + + span_list <- get_span_kableExtra(tab) + + # escape + if (isTRUE(escape) && isTRUE(output_format %in% c("latex", "html", "typst"))) { + tmp <- escape_everything( + tab = tab, + output_format = output_format, + span_list = span_list, + title = title, + notes = notes) + tab <- tmp$tab + title <- tmp$title + notes <- tmp$notes + span_list <- tmp$span_list + } + # new variable "kable_format" because "kableExtra" and "html" both produce # html, but we need to distinguish the two. if (settings_equal("output_format", c("latex", "latex_tabular"))) { @@ -34,27 +52,16 @@ factory_kableExtra <- function(tab, "position", "centering", "vline", "toprule", "bottomrule", "midrule", "caption.short", "table.envir", "col.names") - # kableExtra::kbl and knitr::kable do not respect the `escape` argument for captions. - # this will never be fixed upstream because of backward compatibility - title <- escape_string(title) - - # don't escape \\label{} calls - if (isTRUE(kable_format == "latex")) { - title <- sub("\\\\textbackslash\\{\\}label\\\\\\{(.*)\\\\}", "\\\\label{\\1}", title) - } - arguments <- c( list(...), "caption" = title, "format" = kable_format, "booktabs" = TRUE, + "escape" = FALSE, # never use kableExtra's default escape; inconsistent "linesep" = "", "row.names" = NULL ) - ## never use `kableExtra`'s default escape - arguments$escape <- FALSE - ## siunitx in preamble extra_siunitx <- " \\newcolumntype{d}{S[ @@ -84,7 +91,6 @@ factory_kableExtra <- function(tab, tab[[i]] <- ifelse(grepl("[0-9]", tab[[i]]), sprintf("$%s$", tab[[i]]), tab[[i]]) } } - } if (any(grepl("d", align))) { ## protect column labels @@ -93,17 +99,6 @@ factory_kableExtra <- function(tab, arguments[["align"]] <- align } - # span: compute - span_list <- get_span_kableExtra(tab) - if (!is.null(span_list) && settings_equal("output_format", c("kableExtra", "html", "latex"))) { - column_names <- attr(span_list, "column_names") - if (!is.null(column_names)) { - colnames(tab) <- column_names - } - } else { - colnames(tab) <- gsub("\\|{4}", " / ", colnames(tab)) - } - # Issue #669: <0.001 gets printed as a tag in HTML if (settings_equal("output_format", c("kableExtra", "html"))) { for (i in seq_along(tab)) { @@ -181,6 +176,7 @@ factory_kableExtra <- function(tab, # span: apply (not supported in markdown) if (!is.null(span_list) && settings_equal("output_format", c("kableExtra", "latex", "html"))) { for (i in 1:length(span_list)) { + sp <- span_list[[i]] names(span_list[[i]]) <- gsub(" ", " ", names(span_list[[i]])) out <- kableExtra::add_header_above(out, span_list[[i]], escape = TRUE) } diff --git a/R/factory_tinytable.R b/R/factory_tinytable.R index c3030825a..3ae6d8916 100644 --- a/R/factory_tinytable.R +++ b/R/factory_tinytable.R @@ -1,13 +1,3 @@ -# TODO -# span -# hrule -# hgroup -# hindent -# dot align -# tab[[i]][idx] <- gsub("<", "<", tab[[i]][idx]) -# tab[[i]][idx] <- gsub(">", ">", tab[[i]][idx]) - - #' Internal function to build table with `tinytable` #' #' @inheritParams factory_gt @@ -25,25 +15,45 @@ factory_tinytable <- function(tab, insight::check_if_installed("tinytable") + output_format <- settings_get("output_format") - # tinytable arguments - valid <- c("x", "theme", "placement", "width", "digits", "notes", "caption") + span_list <- get_span_kableExtra(tab) - arguments <- list( - caption = title, - align = align - ) - if (length(notes) > 1) arguments$notes <- as.list(notes) - arguments <- c(arguments, list(...)) + # colnames with or without spans: before escape and for all span/no-span + if (is.null(span_list)) { + if (!is.null(colnames(tab))) { + colnames(tab) <- gsub("\\|{4}", " / ", colnames(tab)) + } + } else { + colnames(tab) <- attr(span_list, "column_names") + } + + # escape + if (isTRUE(escape) && isTRUE(output_format %in% c("latex", "html", "typst", "tinytable"))) { + tmp <- escape_everything( + tab = tab, + output_format = output_format, + span_list = span_list, + title = title, + notes = notes) + tab <- tmp$tab + title <- tmp$title + notes <- tmp$notes + span_list <- tmp$span_list + } # create tables with combined arguments - arguments <- arguments[base::intersect(names(arguments), valid)] + arguments <- list(caption = title) + if (length(notes) > 1) { + arguments$notes <- as.list(notes) + } else { + arguments$notes <- notes + } + arguments <- c(arguments, list(...)) + arguments <- arguments[base::intersect(names(arguments), c("x", "theme", "placement", "width", "caption", "align", "notes"))] arguments <- c(list(tab), arguments) out <- do.call(tinytable::tt, arguments) - if (isTRUE(escape)) { - out <- tinytable::format_tt(out, escape = escape) - } # align: other factories require a vector of "c", "l", "r", etc. # before span because those should be centered @@ -54,12 +64,8 @@ factory_tinytable <- function(tab, } # span: compute - span_list <- get_span_kableExtra(tab) + # after align, otherwise span alignment is overridden if (!is.null(span_list)) { - column_names <- attr(span_list, "column_names") - if (!is.null(column_names)) { - colnames(out) <- column_names - } for (i in seq_along(span_list)) { sp <- cumsum(span_list[[i]]) sp <- as.list(sp) @@ -68,22 +74,62 @@ factory_tinytable <- function(tab, out <- tinytable::group_tt(out, j = sp) out <- tinytable::style_tt(out, i = -i, align = "c") } - } else { - colnames(out) <- gsub("\\|{4}", " / ", colnames(out)) } - if (!is.null(hrule)) { for (h in hrule) { out <- tinytable::style_tt(out, i = h - 1, line = "b", line_width = .05) } } - # output - if (is.null(settings_get("output_file"))) { - return(out) - } else { + # write to file + if (!is.null(settings_get("output_file"))) { tinytable::save_tt(out, output = settings_get("output_file"), overwrite = TRUE) + return(invisible()) + } + + # html & latex get a new class to use print.modelsummary_string + if (settings_equal("output_format", c("latex", "typst", "html", "markdown"))) { + out <- tinytable::save_tt(out, output = settings_get("output_format"), overwrite = TRUE) + class(out) <- c("modelsummary_string", class(out)) + } + + return(invisible(out)) + +} + + + +escape_everything <- function(tab, output_format, span_list, title, notes) { + # body: do not escape siunitx \num{} + for (col in seq_len(ncol(tab))) { + tab[[col]] <- ifelse( + grepl("\\\\num\\{", tab[[col]]), + tab[[col]], + tinytable::format_tt(tab[, col], escape = output_format)) + } + + for (i in seq_along(span_list)) { + names(span_list[[i]]) <- tinytable::format_tt(names(span_list[[i]]), escape = output_format) + } + + for (i in seq_along(notes)) { + notes[[i]] <- tinytable::format_tt(notes[[i]], escape = output_format) + } + + if (!is.null(colnames(tab))) { + colnames(tab) <- tinytable::format_tt(colnames(tab), escape = output_format) + } + + # do not escape if title includes a LaTeX label + if (isTRUE(checkmate::check_string(title)) && !isTRUE(grepl("\\\\label\\{", title))) { + title <- tinytable::format_tt(title, escape = output_format) + } + + if (isTRUE(output_format == "latex") && any(grepl(" < ", notes))) { + notes <- gsub(" < ", " $<$ ", notes) } + out <- list(tab = tab, title = title, notes = notes, span_list = span_list) + return(out) } diff --git a/R/format_gof.R b/R/format_gof.R index 396fb0e6f..3fc34c5b4 100644 --- a/R/format_gof.R +++ b/R/format_gof.R @@ -15,9 +15,6 @@ format_gof <- function(gof, fmt, gof_map, ...) { if (is.factor(gof[[i]])) { gof[[i]] <- as.character(gof[[i]]) } - if (is.character(gof[[i]])) { - gof[[i]] <- escape_string(gof[[i]]) - } } @@ -57,9 +54,6 @@ format_gof <- function(gof, fmt, gof_map, ...) { out <- stats::na.omit(out) } - # escape term names (fixest: FE: x_1) - out$term <- escape_string(out$term) - # output row.names(out) <- NULL return(out) diff --git a/R/map_estimates.R b/R/map_estimates.R index 2f17cb0b3..4516aacb7 100644 --- a/R/map_estimates.R +++ b/R/map_estimates.R @@ -107,14 +107,5 @@ modelsummary(mod, coef_omit = "^(?!.*ei|.*pt)") group_map) } - ## escape if needed - ## (must be done after rename/map, otherwise all rows are dropped) - cols <- intersect( - colnames(estimates), - c("group", "term", "model", group_name)) - for (col in cols) { - estimates[[col]] <- escape_string(estimates[[col]]) - } - return(estimates) } \ No newline at end of file diff --git a/R/modelplot.R b/R/modelplot.R index 3448a85b3..af9f7e808 100644 --- a/R/modelplot.R +++ b/R/modelplot.R @@ -109,12 +109,6 @@ modelplot <- function(models, ellip <- list(...) - if ("statistic_override" %in% names(ellip)) { - if (!is.null(vcov)) { - stop("The `vcov` and `statistic_override` arguments cannot be used at the same time. The `statistic_override` argument is deprecated. Please use `vcov` instead.") - } - } - if (is.null(conf_level)) { estimate <- "estimate" } else { diff --git a/R/modelsummary.R b/R/modelsummary.R index 56a9d1d05..016cfeb36 100644 --- a/R/modelsummary.R +++ b/R/modelsummary.R @@ -12,7 +12,7 @@ globalVariables(c('.', 'term', 'part', 'estimate', 'conf.high', 'conf.low', #' #' Create beautiful and customizable tables to summarize several statistical #' models side-by-side. This function supports dozens of statistical models, -#' and it can produce tables in HTML, LaTeX, Word, Markdown, PDF, PowerPoint, +#' and it can produce tables in HTML, LaTeX, Word, Markdown, Typst, PDF, PowerPoint, #' Excel, RTF, JPG, or PNG. The appearance of the tables can be customized #' extensively by specifying the `output` argument, and by using functions from #' one of the supported table customization packages: `tinytable`, `kableExtra`, `gt`, @@ -39,8 +39,8 @@ globalVariables(c('.', 'term', 'part', 'estimate', 'conf.high', 'conf.low', #' * Nested list of models: When using the `shape="rbind"` argument, `models` can be a nested list of models to display "panels" or "stacks" of regression models. See the `shape` argument documentation and examples below. #' @param output filename or object type (character string) #' * Supported filename extensions: .docx, .html, .tex, .md, .txt, .csv, .xlsx, .png, .jpg -#' * Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the `modelsummary` function. -#' * The "default" output format can be set to "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" +#' * Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "typst", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the `modelsummary` function. +#' * The "default" output format can be set to "tinytable", "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" #' - If the user does not choose a default value, the packages listed above are tried in sequence. #' - Session-specific configuration: `options("modelsummary_factory_default" = "gt")` #' - Persistent configuration: `config_modelsummary(output = "markdown")` @@ -176,7 +176,7 @@ globalVariables(c('.', 'term', 'part', 'estimate', 'conf.high', 'conf.low', #' - `standardize`, `centrality`, `dispersion`, `test`, `ci_method`, `prior`, `diagnostic`, `rope_range`, `power`, `cluster`, etc. #' + [performance::model_performance] extracts goodness-of-fit statistics. Available arguments depend on model type, but include: #' - `metrics`, `estimator`, etc. -#' + [kableExtra::kbl] or [gt::gt] draw tables, depending on the value of the `output` argument. +#' + [tinytable::tt], [kableExtra::kbl] or [gt::gt] draw tables, depending on the value of the `output` argument. #' @return a regression table in a format determined by the `output` argument. #' @importFrom generics glance tidy #' @@ -483,14 +483,13 @@ modelsummary <- function( model_names <- names(models) } model_names <- pad(model_names) - model_names <- escape_string(model_names) # kableExtra sometimes converts (1), (2) to list items, which breaks formatting # insert think white non-breaking space # don't do this now when called from modelsummary_rbind() or there are escape issues if (!settings_equal("function_called", "modelsummary_rbind") && all(grepl("^\\(\\d+\\)$", model_names)) && - settings_equal("output_format", c("html", "kableExtra"))) { + settings_equal("output_format", "kableExtra")) { model_names <- paste0(" ", model_names) } @@ -589,7 +588,6 @@ modelsummary <- function( if ("term" %in% colnames(est)) { if (!is.null(coef_map)) { term_order <- coef_map - term_order <- escape_string(term_order) } est$term <- factor(est$term, unique(term_order)) @@ -733,7 +731,6 @@ modelsummary <- function( } else { notes <- c(stars_note, notes) } - notes <- escape_string(notes) } # data.frame output keeps redundant info diff --git a/R/modelsummary_rbind.R b/R/modelsummary_rbind.R index e289d80e5..f22d2cf53 100644 --- a/R/modelsummary_rbind.R +++ b/R/modelsummary_rbind.R @@ -85,7 +85,6 @@ modelsummary_rbind <- function( panel_names <- names(panels) } panel_names <- pad(panel_names) - panel_names <- escape_string(panel_names) # If there are no common model names but all the panels have the same number # of models, we make assumptions. @@ -208,7 +207,7 @@ modelsummary_rbind <- function( tab[is.na(tab)] <- "" # pad - colnames(tab) <- pad(escape_string(colnames(tab))) + colnames(tab) <- pad(colnames(tab)) # group rows by panel: kableExtra if (isTRUE(nrow(gof_same) > 0)) { diff --git a/R/sanitize_output.R b/R/sanitize_output.R index f0a05c6c6..112e4dc0e 100644 --- a/R/sanitize_output.R +++ b/R/sanitize_output.R @@ -27,11 +27,12 @@ sanitize_output <- function(output) { stop("The `output` argument must be a string. Type `?modelsummary` for details. This error is sometimes raised when users supply multiple models to `modelsummary` but forget to wrap them in a list. This works: `modelsummary(list(model1, model2))`. This does *not* work: `modelsummary(model1, model2)`") } - object_types <- c('default', 'gt', 'kableExtra', 'flextable', 'huxtable', 'DT', "tinytable", - 'html', 'jupyter', 'latex', 'latex_tabular', 'markdown', - 'dataframe', 'data.frame', 'typst', 'modelsummary_list') - extension_types <- c('html', 'tex', 'md', 'txt', 'docx', 'pptx', 'rtf', - 'jpg', 'png', 'csv', 'xlsx') + object_types <- c('default', + 'tinytable', 'gt', 'kableExtra', 'flextable', 'huxtable', 'DT', + 'html', 'jupyter', 'latex', 'latex_tabular', 'markdown', + 'dataframe', 'data.frame', 'typst', 'modelsummary_list') + extension_types <- c( + 'html', 'tex', 'md', 'txt', 'docx', 'pptx', 'rtf', 'jpg', 'png', 'csv', 'xlsx') checkmate::assert_string(output) @@ -79,15 +80,15 @@ sanitize_output <- function(output) { "kableExtra" = "kableExtra", "latex_tabular" = "kableExtra", "modelsummary_list" = "modelsummary_list", - "typst" = "typst", - "markdown" = get_factory_name("markdown", default = "modelsummary"), - "jupyter" = get_factory_name("html", default = "kableExtra"), - "latex" = get_factory_name("latex", default = "kableExtra"), - "html" = get_factory_name("html", default = "kableExtra"), + "typst" = "tinytable", + "markdown" = get_factory_name("markdown", default = "tinytable"), + "jupyter" = get_factory_name("html", default = "tinytable"), + "latex" = get_factory_name("latex", default = "tinytable"), + "html" = get_factory_name("html", default = "tinytable"), + "png" = get_factory_name("png", default = "tinytable"), + "word" = get_factory_name("word", default = "tinytable"), "jpg" = get_factory_name("jpg", default = "kableExtra"), - "png" = get_factory_name("png", default = "kableExtra"), "rtf" = get_factory_name("rtf", default = "gt"), - "word" = get_factory_name("word", default = "flextable"), "powerpoint" = get_factory_name("powerpoint", default = "flextable")) ## sanity check: are user-supplied global options ok? @@ -103,12 +104,12 @@ sanitize_output <- function(output) { output <- config_get("factory_default") } if (is.null(output)) { - if (isTRUE(insight::check_if_installed("kableExtra", quietly = TRUE))) { + if (isTRUE(insight::check_if_installed("tinytable", quietly = TRUE))) { + output <- "tinytable" + } else if (isTRUE(insight::check_if_installed("kableExtra", quietly = TRUE))) { output <- "kableExtra" } else if (isTRUE(insight::check_if_installed("gt", quietly = TRUE))) { output <- "gt" - } else if (isTRUE(insight::check_if_installed("tinytable", quietly = TRUE))) { - output <- "tinytable" } else if (isTRUE(insight::check_if_installed("flextable", quietly = TRUE))) { output <- "flextable" } else if (isTRUE(insight::check_if_installed("huxtable", quietly = TRUE))) { @@ -201,15 +202,16 @@ sanitize_output <- function(output) { if (settings_equal("format_numeric_latex", "siunitx") && (output %in% c("latex", "latex_tabular") || tools::file_ext(output) == "tex")) { msg <- 'To compile a LaTeX document with this table, the following commands must be placed in the document preamble: -\\usepackage{booktabs} -\\usepackage{siunitx} -\\newcolumntype{d}{S[ - input-open-uncertainty=, - input-close-uncertainty=, - parse-numbers = false, - table-align-text-pre=false, - table-align-text-post=false - ]} +\\usepackage{tabularray} +\\usepackage{float} +\\usepackage{graphicx} +\\usepackage{codehigh} +\\usepackage[normalem]{ulem} +\\UseTblrLibrary{booktabs} +\\UseTblrLibrary{siunitx} +\\newcommand{\\tinytableTabularrayUnderline}[1]{\\underline{#1}} +\\newcommand{\\tinytableTabularrayStrikeout}[1]{\\sout{#1}} +\\NewTableCommand{\\tinytableDefineColor}[3]{\\definecolor{#1}{#2}{#3}} To disable `siunitx` and prevent `modelsummary` from wrapping numeric entries in `\\num{}`, call: diff --git a/R/sanitize_vcov.R b/R/sanitize_vcov.R index d5280ec8c..194884d26 100644 --- a/R/sanitize_vcov.R +++ b/R/sanitize_vcov.R @@ -6,11 +6,6 @@ sanitize_vcov <- function(vcov, models, ...) { ellip <- list(...) number_of_models <- length(models) - # sanity_ellipsis must be called before sanity_vcov - if ("statistic_override" %in% names(ellip)) { - vcov <- ellip[["statistic_override"]] - } - if (is.null(vcov)) { vcov <- list(vcov) names(vcov) <- "" diff --git a/R/sanity_checks.R b/R/sanity_checks.R index 655e40d5b..b9eb3532e 100644 --- a/R/sanity_checks.R +++ b/R/sanity_checks.R @@ -47,9 +47,6 @@ sanity_ellipsis <- function(vcov, ...) { call. = FALSE) } - if (!is.null(vcov) && ("statistic_override" %in% names(ellip))) { - stop("The `vcov` and `statistic_override` arguments cannot be used at the same time. The `statistic_override` argument is deprecated. Please use `vcov` instead.") - } } diff --git a/R/zzz.R b/R/zzz.R index 5d8b9c1ce..323be3de2 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,14 +1,13 @@ .onAttach <- function(libname, pkgname){ msg <- insight::format_message( -"Version 2.0.0 of `modelsummary`, to be released soon, will introduce a breaking change: The default table-drawing package will be `tinytable` instead of `kableExtra`. All currently supported table-drawing packages will continue to be supported for the foreseeable future, including `kableExtra`, `gt`, `huxtable`, `flextable, and `DT`.", +"`modelsummary` 2.0.0 uses `tinytable` as its default table-drawing package. Learn more at:", "", -"You can always call the `config_modelsummary()` function to change the default table-drawing package in persistent fashion. To try `tinytable` now:", +"https://vincentarelbundock.github.io/tinytable/", "", -"config_modelsummary(factory_default = 'tinytable')", +"You can revert to `kableExtra` or other backend for one session or persistently with:", "", -"To set the default back to `kableExtra`:", -"", -"config_modelsummary(factory_default = 'kableExtra')" +"options(modelsummary_factory_default = 'kableExtra')", +"config_modelsummary(factory_default = 'gt')" ) packageStartupMessage(msg) } diff --git a/inst/tinytest/_tinysnapshot/align-md_dcolumn.txt b/inst/tinytest/_tinysnapshot/align-md_dcolumn.txt index 9de8878ca..8e24b5cb8 100644 --- a/inst/tinytest/_tinysnapshot/align-md_dcolumn.txt +++ b/inst/tinytest/_tinysnapshot/align-md_dcolumn.txt @@ -1,24 +1,46 @@ -| | (1) | -|:-------------|----------:| -| (Intercept) | 24.447 | -| | (2.571) | -| I(hp/1000) | -46.879 | -| | (14.515) | -| am | 5.163 | -| | (1.454) | -| vs | 2.569 | -| | (1.942) | -| factor(cyl)6 | -2.652 | -| | (1.796) | -| factor(cyl)8 | -0.277 | -| | (3.487) | -| Num.Obs. | 32 | -| R2 | 0.836 | -| R2 Adj. | 0.804 | -| AIC | 160.9 | -| BIC | 171.2 | -| Log.Lik. | -73.460 | -| F | 26.491 | -| RMSE | 2.40 | ++--------------+-----------+ +| | (1) | ++==============+===========+ +| (Intercept) | 24.447 | ++--------------+-----------+ +| | (2.571) | ++--------------+-----------+ +| I(hp/1000) | -46.879 | ++--------------+-----------+ +| | (14.515) | ++--------------+-----------+ +| am | 5.163 | ++--------------+-----------+ +| | (1.454) | ++--------------+-----------+ +| vs | 2.569 | ++--------------+-----------+ +| | (1.942) | ++--------------+-----------+ +| factor(cyl)6 | -2.652 | ++--------------+-----------+ +| | (1.796) | ++--------------+-----------+ +| factor(cyl)8 | -0.277 | ++--------------+-----------+ +| | (3.487) | ++--------------+-----------+ +| Num.Obs. | 32 | ++--------------+-----------+ +| R2 | 0.836 | ++--------------+-----------+ +| R2 Adj. | 0.804 | ++--------------+-----------+ +| AIC | 160.9 | ++--------------+-----------+ +| BIC | 171.2 | ++--------------+-----------+ +| Log.Lik. | -73.460 | ++--------------+-----------+ +| F | 26.491 | ++--------------+-----------+ +| RMSE | 2.40 | ++--------------+-----------+ + diff --git a/inst/tinytest/_tinysnapshot/datasummary_balance-escape_FALSE.txt b/inst/tinytest/_tinysnapshot/datasummary_balance-escape_FALSE.txt new file mode 100644 index 000000000..87dc58a70 --- /dev/null +++ b/inst/tinytest/_tinysnapshot/datasummary_balance-escape_FALSE.txt @@ -0,0 +1,35 @@ +\begin{table} +\centering +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]Q[]Q[]Q[]Q[]}, +cell{1}{1}={c=1,}{halign=c,}, +cell{1}{2}={c=2,}{halign=c,}, +cell{1}{4}={c=2,}{halign=c,}, +cell{1}{6}={c=2,}{halign=c,}, +column{1}={halign=l,}, +column{2}={halign=r,}, +column{3}={halign=r,}, +column{4}={halign=r,}, +column{5}={halign=r,}, +column{6}={halign=r,}, +column{7}={halign=r,}, +row{1}={halign=c,}, +} %% tabularray inner close +\toprule +& no_no (N=18) & & yes_yes (N=14) & & & \\ \cmidrule[lr]{1-1}\cmidrule[lr]{2-3}\cmidrule[lr]{4-5}\cmidrule[lr]{6-7} +& Mean & Std. Dev. & Mean & Std. Dev. & Diff. in Means & Std. Error \\ \midrule %% TinyTableHeader +mpg & 16.6 & 3.9 & 24.6 & 5.4 & 7.9 & 1.7 \\ +cyl & 7.4 & 1.1 & 4.6 & 0.9 & -2.9 & 0.4 \\ +disp & 307.1 & 106.8 & 132.5 & 56.9 & -174.7 & 29.4 \\ +hp & 189.7 & 60.3 & 91.4 & 24.4 & -98.4 & 15.6 \\ +drat & 3.4 & 0.5 & 3.9 & 0.5 & 0.5 & 0.2 \\ +wt & 3.7 & 0.9 & 2.6 & 0.7 & -1.1 & 0.3 \\ +qsec & 16.7 & 1.1 & 19.3 & 1.4 & 2.6 & 0.4 \\ +am & 0.3 & 0.5 & 0.5 & 0.5 & 0.2 & 0.2 \\ +gear & 3.6 & 0.9 & 3.9 & 0.5 & 0.3 & 0.2 \\ +carb & 3.6 & 1.5 & 1.8 & 1.1 & -1.8 & 0.5 \\ +\bottomrule +\end{tblr} +\end{table} diff --git a/inst/tinytest/_tinysnapshot/datasummary_balance-escape_TRUE.txt b/inst/tinytest/_tinysnapshot/datasummary_balance-escape_TRUE.txt index 014f4cd1a..3a06fc160 100644 --- a/inst/tinytest/_tinysnapshot/datasummary_balance-escape_TRUE.txt +++ b/inst/tinytest/_tinysnapshot/datasummary_balance-escape_TRUE.txt @@ -1,21 +1,35 @@ \begin{table} \centering -\begin{tabular}[t]{lrrrrrr} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]Q[]Q[]Q[]Q[]}, +cell{1}{1}={c=1,}{halign=c,}, +cell{1}{2}={c=2,}{halign=c,}, +cell{1}{4}={c=2,}{halign=c,}, +cell{1}{6}={c=2,}{halign=c,}, +column{1}={halign=l,}, +column{2}={halign=r,}, +column{3}={halign=r,}, +column{4}={halign=r,}, +column{5}={halign=r,}, +column{6}={halign=r,}, +column{7}={halign=r,}, +row{1}={halign=c,}, +} %% tabularray inner close \toprule -\multicolumn{1}{c}{ } & \multicolumn{2}{c}{no\_no (N=18)} & \multicolumn{2}{c}{yes\_yes (N=14)} & \multicolumn{2}{c}{ } \\ -\cmidrule(l{3pt}r{3pt}){2-3} \cmidrule(l{3pt}r{3pt}){4-5} - & Mean & Std. Dev. & Mean & Std. Dev. & Diff. in Means & Std. Error\\ -\midrule -mpg & 16.6 & 3.9 & 24.6 & 5.4 & 7.9 & 1.7\\ -cyl & 7.4 & 1.1 & 4.6 & 0.9 & -2.9 & 0.4\\ -disp & 307.1 & 106.8 & 132.5 & 56.9 & -174.7 & 29.4\\ -hp & 189.7 & 60.3 & 91.4 & 24.4 & -98.4 & 15.6\\ -drat & 3.4 & 0.5 & 3.9 & 0.5 & 0.5 & 0.2\\ -wt & 3.7 & 0.9 & 2.6 & 0.7 & -1.1 & 0.3\\ -qsec & 16.7 & 1.1 & 19.3 & 1.4 & 2.6 & 0.4\\ -am & 0.3 & 0.5 & 0.5 & 0.5 & 0.2 & 0.2\\ -gear & 3.6 & 0.9 & 3.9 & 0.5 & 0.3 & 0.2\\ -carb & 3.6 & 1.5 & 1.8 & 1.1 & -1.8 & 0.5\\ +& no\_no (N=18) & & yes\_yes (N=14) & & & \\ \cmidrule[lr]{1-1}\cmidrule[lr]{2-3}\cmidrule[lr]{4-5}\cmidrule[lr]{6-7} +& Mean & Std. Dev. & Mean & Std. Dev. & Diff. in Means & Std. Error \\ \midrule %% TinyTableHeader +mpg & 16.6 & 3.9 & 24.6 & 5.4 & 7.9 & 1.7 \\ +cyl & 7.4 & 1.1 & 4.6 & 0.9 & -2.9 & 0.4 \\ +disp & 307.1 & 106.8 & 132.5 & 56.9 & -174.7 & 29.4 \\ +hp & 189.7 & 60.3 & 91.4 & 24.4 & -98.4 & 15.6 \\ +drat & 3.4 & 0.5 & 3.9 & 0.5 & 0.5 & 0.2 \\ +wt & 3.7 & 0.9 & 2.6 & 0.7 & -1.1 & 0.3 \\ +qsec & 16.7 & 1.1 & 19.3 & 1.4 & 2.6 & 0.4 \\ +am & 0.3 & 0.5 & 0.5 & 0.5 & 0.2 & 0.2 \\ +gear & 3.6 & 0.9 & 3.9 & 0.5 & 0.3 & 0.2 \\ +carb & 3.6 & 1.5 & 1.8 & 1.1 & -1.8 & 0.5 \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/escape-correlation_latex.txt b/inst/tinytest/_tinysnapshot/escape-correlation_latex.txt index 926fb75e4..b0c5d1aa2 100644 --- a/inst/tinytest/_tinysnapshot/escape-correlation_latex.txt +++ b/inst/tinytest/_tinysnapshot/escape-correlation_latex.txt @@ -1,20 +1,35 @@ \begin{table} \centering -\begin{tabular}[t]{lrrrrrrrrrrr} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=r,}, +column{3}={halign=r,}, +column{4}={halign=r,}, +column{5}={halign=r,}, +column{6}={halign=r,}, +column{7}={halign=r,}, +column{8}={halign=r,}, +column{9}={halign=r,}, +column{10}={halign=r,}, +column{11}={halign=r,}, +column{12}={halign=r,}, +} %% tabularray inner close \toprule - & under\_score & oh\&yeah2 & disp & hp & drat & wt & qsec & vs & am & gear & carb\\ -\midrule -under\_score & 1 & . & . & . & . & . & . & . & . & . & .\\ -oh\&yeah2 & \num{-.85} & 1 & . & . & . & . & . & . & . & . & .\\ -disp & \num{-.85} & \num{.90} & 1 & . & . & . & . & . & . & . & .\\ -hp & \num{-.78} & \num{.83} & \num{.79} & 1 & . & . & . & . & . & . & .\\ -drat & \num{.68} & \num{-.70} & \num{-.71} & \num{-.45} & 1 & . & . & . & . & . & .\\ -wt & \num{-.87} & \num{.78} & \num{.89} & \num{.66} & \num{-.71} & 1 & . & . & . & . & .\\ -qsec & \num{.42} & \num{-.59} & \num{-.43} & \num{-.71} & \num{.09} & \num{-.17} & 1 & . & . & . & .\\ -vs & \num{.66} & \num{-.81} & \num{-.71} & \num{-.72} & \num{.44} & \num{-.55} & \num{.74} & 1 & . & . & .\\ -am & \num{.60} & \num{-.52} & \num{-.59} & \num{-.24} & \num{.71} & \num{-.69} & \num{-.23} & \num{.17} & 1 & . & .\\ -gear & \num{.48} & \num{-.49} & \num{-.56} & \num{-.13} & \num{.70} & \num{-.58} & \num{-.21} & \num{.21} & \num{.79} & 1 & .\\ -carb & \num{-.55} & \num{.53} & \num{.39} & \num{.75} & \num{-.09} & \num{.43} & \num{-.66} & \num{-.57} & \num{.06} & \num{.27} & 1\\ +& under\_score & oh\&yeah2 & disp & hp & drat & wt & qsec & vs & am & gear & carb \\ \midrule %% TinyTableHeader +under\_score & 1 & . & . & . & . & . & . & . & . & . & . \\ +oh\&yeah2 & \num{-.85} & 1 & . & . & . & . & . & . & . & . & . \\ +disp & \num{-.85} & \num{.90} & 1 & . & . & . & . & . & . & . & . \\ +hp & \num{-.78} & \num{.83} & \num{.79} & 1 & . & . & . & . & . & . & . \\ +drat & \num{.68} & \num{-.70} & \num{-.71} & \num{-.45} & 1 & . & . & . & . & . & . \\ +wt & \num{-.87} & \num{.78} & \num{.89} & \num{.66} & \num{-.71} & 1 & . & . & . & . & . \\ +qsec & \num{.42} & \num{-.59} & \num{-.43} & \num{-.71} & \num{.09} & \num{-.17} & 1 & . & . & . & . \\ +vs & \num{.66} & \num{-.81} & \num{-.71} & \num{-.72} & \num{.44} & \num{-.55} & \num{.74} & 1 & . & . & . \\ +am & \num{.60} & \num{-.52} & \num{-.59} & \num{-.24} & \num{.71} & \num{-.69} & \num{-.23} & \num{.17} & 1 & . & . \\ +gear & \num{.48} & \num{-.49} & \num{-.56} & \num{-.13} & \num{.70} & \num{-.58} & \num{-.21} & \num{.21} & \num{.79} & 1 & . \\ +carb & \num{-.55} & \num{.53} & \num{.39} & \num{.75} & \num{-.09} & \num{.43} & \num{-.66} & \num{-.57} & \num{.06} & \num{.27} & 1 \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/escape-correlation_latex_FALSE.txt b/inst/tinytest/_tinysnapshot/escape-correlation_latex_FALSE.txt index 3fce6fb46..b0c5d1aa2 100644 --- a/inst/tinytest/_tinysnapshot/escape-correlation_latex_FALSE.txt +++ b/inst/tinytest/_tinysnapshot/escape-correlation_latex_FALSE.txt @@ -1,20 +1,35 @@ \begin{table} \centering -\begin{tabular}[t]{lrrrrrrrrrrr} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=r,}, +column{3}={halign=r,}, +column{4}={halign=r,}, +column{5}={halign=r,}, +column{6}={halign=r,}, +column{7}={halign=r,}, +column{8}={halign=r,}, +column{9}={halign=r,}, +column{10}={halign=r,}, +column{11}={halign=r,}, +column{12}={halign=r,}, +} %% tabularray inner close \toprule - & under_score & oh&yeah2 & disp & hp & drat & wt & qsec & vs & am & gear & carb\\ -\midrule -under_score & 1 & . & . & . & . & . & . & . & . & . & .\\ -oh&yeah2 & \num{-.85} & 1 & . & . & . & . & . & . & . & . & .\\ -disp & \num{-.85} & \num{.90} & 1 & . & . & . & . & . & . & . & .\\ -hp & \num{-.78} & \num{.83} & \num{.79} & 1 & . & . & . & . & . & . & .\\ -drat & \num{.68} & \num{-.70} & \num{-.71} & \num{-.45} & 1 & . & . & . & . & . & .\\ -wt & \num{-.87} & \num{.78} & \num{.89} & \num{.66} & \num{-.71} & 1 & . & . & . & . & .\\ -qsec & \num{.42} & \num{-.59} & \num{-.43} & \num{-.71} & \num{.09} & \num{-.17} & 1 & . & . & . & .\\ -vs & \num{.66} & \num{-.81} & \num{-.71} & \num{-.72} & \num{.44} & \num{-.55} & \num{.74} & 1 & . & . & .\\ -am & \num{.60} & \num{-.52} & \num{-.59} & \num{-.24} & \num{.71} & \num{-.69} & \num{-.23} & \num{.17} & 1 & . & .\\ -gear & \num{.48} & \num{-.49} & \num{-.56} & \num{-.13} & \num{.70} & \num{-.58} & \num{-.21} & \num{.21} & \num{.79} & 1 & .\\ -carb & \num{-.55} & \num{.53} & \num{.39} & \num{.75} & \num{-.09} & \num{.43} & \num{-.66} & \num{-.57} & \num{.06} & \num{.27} & 1\\ +& under\_score & oh\&yeah2 & disp & hp & drat & wt & qsec & vs & am & gear & carb \\ \midrule %% TinyTableHeader +under\_score & 1 & . & . & . & . & . & . & . & . & . & . \\ +oh\&yeah2 & \num{-.85} & 1 & . & . & . & . & . & . & . & . & . \\ +disp & \num{-.85} & \num{.90} & 1 & . & . & . & . & . & . & . & . \\ +hp & \num{-.78} & \num{.83} & \num{.79} & 1 & . & . & . & . & . & . & . \\ +drat & \num{.68} & \num{-.70} & \num{-.71} & \num{-.45} & 1 & . & . & . & . & . & . \\ +wt & \num{-.87} & \num{.78} & \num{.89} & \num{.66} & \num{-.71} & 1 & . & . & . & . & . \\ +qsec & \num{.42} & \num{-.59} & \num{-.43} & \num{-.71} & \num{.09} & \num{-.17} & 1 & . & . & . & . \\ +vs & \num{.66} & \num{-.81} & \num{-.71} & \num{-.72} & \num{.44} & \num{-.55} & \num{.74} & 1 & . & . & . \\ +am & \num{.60} & \num{-.52} & \num{-.59} & \num{-.24} & \num{.71} & \num{-.69} & \num{-.23} & \num{.17} & 1 & . & . \\ +gear & \num{.48} & \num{-.49} & \num{-.56} & \num{-.13} & \num{.70} & \num{-.58} & \num{-.21} & \num{.21} & \num{.79} & 1 & . \\ +carb & \num{-.55} & \num{.53} & \num{.39} & \num{.75} & \num{-.09} & \num{.43} & \num{-.66} & \num{-.57} & \num{.06} & \num{.27} & 1 \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/escape-crosstab_latex.txt b/inst/tinytest/_tinysnapshot/escape-crosstab_latex.txt index f92fd9f05..f08884ebd 100644 --- a/inst/tinytest/_tinysnapshot/escape-crosstab_latex.txt +++ b/inst/tinytest/_tinysnapshot/escape-crosstab_latex.txt @@ -1,23 +1,32 @@ \begin{table} \centering -\begin{tabular}[t]{lllrrr} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]Q[]Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=l,}, +column{3}={halign=l,}, +column{4}={halign=r,}, +column{5}={halign=r,}, +column{6}={halign=r,}, +} %% tabularray inner close \toprule -under\_score1 & under\_score2 & & 0 & 1 & All\\ -\midrule -0 & 3 & N & 12 & 0 & 12\\ - & & \% row & \num{100.0} & \num{0.0} & \num{100.0}\\ - & 4 & N & 0 & 2 & 2\\ - & & \% row & \num{0.0} & \num{100.0} & \num{100.0}\\ - & 5 & N & 0 & 4 & 4\\ - & & \% row & \num{0.0} & \num{100.0} & \num{100.0}\\ -1 & 3 & N & 3 & 0 & 3\\ - & & \% row & \num{100.0} & \num{0.0} & \num{100.0}\\ - & 4 & N & 4 & 6 & 10\\ - & & \% row & \num{40.0} & \num{60.0} & \num{100.0}\\ - & 5 & N & 0 & 1 & 1\\ - & & \% row & \num{0.0} & \num{100.0} & \num{100.0}\\ - & All & N & 19 & 13 & 32\\ - & & \% row & \num{59.4} & \num{40.6} & \num{100.0}\\ +under\_score1 & under\_score2 & & 0 & 1 & All \\ \midrule %% TinyTableHeader +0 & 3 & N & 12 & 0 & 12 \\ +& & \% row & \num{100.0} & \num{0.0} & \num{100.0} \\ +& 4 & N & 0 & 2 & 2 \\ +& & \% row & \num{0.0} & \num{100.0} & \num{100.0} \\ +& 5 & N & 0 & 4 & 4 \\ +& & \% row & \num{0.0} & \num{100.0} & \num{100.0} \\ +1 & 3 & N & 3 & 0 & 3 \\ +& & \% row & \num{100.0} & \num{0.0} & \num{100.0} \\ +& 4 & N & 4 & 6 & 10 \\ +& & \% row & \num{40.0} & \num{60.0} & \num{100.0} \\ +& 5 & N & 0 & 1 & 1 \\ +& & \% row & \num{0.0} & \num{100.0} & \num{100.0} \\ +& All & N & 19 & 13 & 32 \\ +& & \% row & \num{59.4} & \num{40.6} & \num{100.0} \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/escape-crosstab_latex_FALSE.txt b/inst/tinytest/_tinysnapshot/escape-crosstab_latex_FALSE.txt index 4a8c4a331..732c0e6be 100644 --- a/inst/tinytest/_tinysnapshot/escape-crosstab_latex_FALSE.txt +++ b/inst/tinytest/_tinysnapshot/escape-crosstab_latex_FALSE.txt @@ -1,23 +1,32 @@ \begin{table} \centering -\begin{tabular}[t]{lllrrr} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]Q[]Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=l,}, +column{3}={halign=l,}, +column{4}={halign=r,}, +column{5}={halign=r,}, +column{6}={halign=r,}, +} %% tabularray inner close \toprule -under_score1 & under_score2 & & 0 & 1 & All\\ -\midrule -0 & 3 & N & 12 & 0 & 12\\ - & & % row & \num{100.0} & \num{0.0} & \num{100.0}\\ - & 4 & N & 0 & 2 & 2\\ - & & % row & \num{0.0} & \num{100.0} & \num{100.0}\\ - & 5 & N & 0 & 4 & 4\\ - & & % row & \num{0.0} & \num{100.0} & \num{100.0}\\ -1 & 3 & N & 3 & 0 & 3\\ - & & % row & \num{100.0} & \num{0.0} & \num{100.0}\\ - & 4 & N & 4 & 6 & 10\\ - & & % row & \num{40.0} & \num{60.0} & \num{100.0}\\ - & 5 & N & 0 & 1 & 1\\ - & & % row & \num{0.0} & \num{100.0} & \num{100.0}\\ - & All & N & 19 & 13 & 32\\ - & & % row & \num{59.4} & \num{40.6} & \num{100.0}\\ +under_score1 & under_score2 & & 0 & 1 & All \\ \midrule %% TinyTableHeader +0 & 3 & N & 12 & 0 & 12 \\ +& & % row & \num{100.0} & \num{0.0} & \num{100.0} \\ +& 4 & N & 0 & 2 & 2 \\ +& & % row & \num{0.0} & \num{100.0} & \num{100.0} \\ +& 5 & N & 0 & 4 & 4 \\ +& & % row & \num{0.0} & \num{100.0} & \num{100.0} \\ +1 & 3 & N & 3 & 0 & 3 \\ +& & % row & \num{100.0} & \num{0.0} & \num{100.0} \\ +& 4 & N & 4 & 6 & 10 \\ +& & % row & \num{40.0} & \num{60.0} & \num{100.0} \\ +& 5 & N & 0 & 1 & 1 \\ +& & % row & \num{0.0} & \num{100.0} & \num{100.0} \\ +& All & N & 19 & 13 & 32 \\ +& & % row & \num{59.4} & \num{40.6} & \num{100.0} \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/escape-datasummary_escape_colnames.txt b/inst/tinytest/_tinysnapshot/escape-datasummary_escape_colnames.txt index 5be9b54e3..ec2e5af67 100644 --- a/inst/tinytest/_tinysnapshot/escape-datasummary_escape_colnames.txt +++ b/inst/tinytest/_tinysnapshot/escape-datasummary_escape_colnames.txt @@ -1,11 +1,17 @@ \begin{table} \centering -\begin{tabular}[t]{lrr} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=r,}, +column{3}={halign=r,}, +} %% tabularray inner close \toprule - & \% & Money \$\$\\ -\midrule -under\_score & \num{20.09} & \num{6.03}\\ -hp & \num{146.69} & \num{68.56}\\ +& \% & Money \$\$ \\ \midrule %% TinyTableHeader +under\_score & \num{20.09} & \num{6.03} \\ +hp & \num{146.69} & \num{68.56} \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/escape-datasummary_escape_colnames_FALSE.txt b/inst/tinytest/_tinysnapshot/escape-datasummary_escape_colnames_FALSE.txt index b5ff6120c..47b2cf862 100644 --- a/inst/tinytest/_tinysnapshot/escape-datasummary_escape_colnames_FALSE.txt +++ b/inst/tinytest/_tinysnapshot/escape-datasummary_escape_colnames_FALSE.txt @@ -1,11 +1,17 @@ \begin{table} \centering -\begin{tabular}[t]{lrr} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=r,}, +column{3}={halign=r,}, +} %% tabularray inner close \toprule - & % & Money $$\\ -\midrule -under_score & \num{20.09} & \num{6.03}\\ -hp & \num{146.69} & \num{68.56}\\ +& % & Money $$ \\ \midrule %% TinyTableHeader +under_score & \num{20.09} & \num{6.03} \\ +hp & \num{146.69} & \num{68.56} \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/escape-hat_I_formula.txt b/inst/tinytest/_tinysnapshot/escape-hat_I_formula.txt index 510e67af9..01582bd17 100644 --- a/inst/tinytest/_tinysnapshot/escape-hat_I_formula.txt +++ b/inst/tinytest/_tinysnapshot/escape-hat_I_formula.txt @@ -1,26 +1,31 @@ \begin{table} \centering -\begin{tabular}[t]{lc} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=c,}, +hline{10}={1,2}{solid, 0.05em, black}, +} %% tabularray inner close \toprule - & (1)\\ -\midrule -(Intercept) & \num{36.016}\\ - & (\num{1.774})\\ -I(wt\textasciicircum{}2) & \num{-1.219}\\ - & (\num{0.268})\\ -disp & \num{-0.043}\\ - & (\num{0.008})\\ -I(wt\textasciicircum{}2) × disp & \num{0.002}\\ - & (\num{0.001})\\ -\midrule -Num.Obs. & \num{32}\\ -R2 & \num{0.840}\\ -R2 Adj. & \num{0.823}\\ -AIC & \num{156.2}\\ -BIC & \num{163.5}\\ -Log.Lik. & \num{-73.088}\\ -F & \num{48.886}\\ -RMSE & \num{2.38}\\ +& (1) \\ \midrule %% TinyTableHeader +(Intercept) & \num{36.016} \\ +& (\num{1.774}) \\ +I(wt\textasciicircum{}2) & \num{-1.219} \\ +& (\num{0.268}) \\ +disp & \num{-0.043} \\ +& (\num{0.008}) \\ +I(wt\textasciicircum{}2) × disp & \num{0.002} \\ +& (\num{0.001}) \\ +Num.Obs. & \num{32} \\ +R2 & \num{0.840} \\ +R2 Adj. & \num{0.823} \\ +AIC & \num{156.2} \\ +BIC & \num{163.5} \\ +Log.Lik. & \num{-73.088} \\ +F & \num{48.886} \\ +RMSE & \num{2.38} \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/escape-hat_fixest.txt b/inst/tinytest/_tinysnapshot/escape-hat_fixest.txt index 5b3790561..0c906624b 100644 --- a/inst/tinytest/_tinysnapshot/escape-hat_fixest.txt +++ b/inst/tinytest/_tinysnapshot/escape-hat_fixest.txt @@ -1,24 +1,29 @@ \begin{table} \centering -\begin{tabular}[t]{lc} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=c,}, +hline{4}={1,2}{solid, 0.05em, black}, +} %% tabularray inner close \toprule - & (1)\\ -\midrule -x1 & \num{0.791}\\ - & (\num{0.127})\\ -\midrule -Num.Obs. & \num{150}\\ -R2 & \num{0.735}\\ -R2 Adj. & \num{0.714}\\ -R2 Within & \num{0.275}\\ -R2 Within Adj. & \num{0.269}\\ -AIC & \num{192.8}\\ -BIC & \num{228.9}\\ -RMSE & \num{0.42}\\ -Std.Errors & by: fe1\textasciicircum{}fe2\\ -FE: fe1 & X\\ -FE: fe2 & X\\ -FE: fe3 & X\\ +& (1) \\ \midrule %% TinyTableHeader +x1 & \num{0.791} \\ +& (\num{0.127}) \\ +Num.Obs. & \num{150} \\ +R2 & \num{0.735} \\ +R2 Adj. & \num{0.714} \\ +R2 Within & \num{0.275} \\ +R2 Within Adj. & \num{0.269} \\ +AIC & \num{192.8} \\ +BIC & \num{228.9} \\ +RMSE & \num{0.42} \\ +Std.Errors & by: fe1\textasciicircum{}fe2 \\ +FE: fe1 & X \\ +FE: fe2 & X \\ +FE: fe3 & X \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/escape-html.txt b/inst/tinytest/_tinysnapshot/escape-html.txt index 2c57905ac..0fc937c49 100644 --- a/inst/tinytest/_tinysnapshot/escape-html.txt +++ b/inst/tinytest/_tinysnapshot/escape-html.txt @@ -1,86 +1,221 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
First&Second Third_Fourth
(Intercept) −103.772 −103.772
(103.551) (103.551)
under_score −3.899 −3.899
(2.072) (2.072)
oh&yeah<sup>2</sup> 29.329 29.329
(7.169) (7.169)
drat 40.961 40.961
(17.115) (17.115)
Num.Obs. 32 32
R2 0.759 0.759
R2 Adj. 0.733 0.733
AIC 324.9 324.9
BIC 332.2 332.2
Log.Lik. −157.443 −157.443
RMSE 33.15 33.15
+ + + + + + tinytable + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
First&SecondThird_Fourth
(Intercept) -103.772 -103.772
(103.551)(103.551)
under_score -3.899 -3.899
(2.072) (2.072)
oh&yeah229.329 29.329
(7.169) (7.169)
drat 40.961 40.961
(17.115) (17.115)
Num.Obs. 32 32
R2 0.759 0.759
R2 Adj. 0.733 0.733
AIC 324.9 324.9
BIC 332.2 332.2
Log.Lik. -157.443 -157.443
RMSE 33.15 33.15
+
+ + + + + + + diff --git a/inst/tinytest/_tinysnapshot/escape-html_escape_FALSE.txt b/inst/tinytest/_tinysnapshot/escape-html_escape_FALSE.txt index 5a180128b..0fc937c49 100644 --- a/inst/tinytest/_tinysnapshot/escape-html_escape_FALSE.txt +++ b/inst/tinytest/_tinysnapshot/escape-html_escape_FALSE.txt @@ -1,86 +1,221 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
First&Second Third_Fourth
(Intercept) −103.772 −103.772
(103.551) (103.551)
under_score −3.899 −3.899
(2.072) (2.072)
oh&yeah2 29.329 29.329
(7.169) (7.169)
drat 40.961 40.961
(17.115) (17.115)
Num.Obs. 32 32
R2 0.759 0.759
R2 Adj. 0.733 0.733
AIC 324.9 324.9
BIC 332.2 332.2
Log.Lik. −157.443 −157.443
RMSE 33.15 33.15
+ + + + + + tinytable + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
First&SecondThird_Fourth
(Intercept) -103.772 -103.772
(103.551)(103.551)
under_score -3.899 -3.899
(2.072) (2.072)
oh&yeah229.329 29.329
(7.169) (7.169)
drat 40.961 40.961
(17.115) (17.115)
Num.Obs. 32 32
R2 0.759 0.759
R2 Adj. 0.733 0.733
AIC 324.9 324.9
BIC 332.2 332.2
Log.Lik. -157.443 -157.443
RMSE 33.15 33.15
+
+ + + + + + + diff --git a/inst/tinytest/_tinysnapshot/escape-latex.txt b/inst/tinytest/_tinysnapshot/escape-latex.txt index c4f2239e4..35b062da7 100644 --- a/inst/tinytest/_tinysnapshot/escape-latex.txt +++ b/inst/tinytest/_tinysnapshot/escape-latex.txt @@ -1,25 +1,31 @@ \begin{table} \centering -\begin{tabular}[t]{lcc} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=c,}, +column{3}={halign=c,}, +hline{10}={1,2,3}{solid, 0.05em, black}, +} %% tabularray inner close \toprule - & First\&Second & Third\_Fourth\\ -\midrule -(Intercept) & \num{-103.772} & \num{-103.772}\\ - & (\num{103.551}) & (\num{103.551})\\ -under\_score & \num{-3.899} & \num{-3.899}\\ - & (\num{2.072}) & (\num{2.072})\\ -oh\&yeah2 & \num{29.329} & \num{29.329}\\ - & (\num{7.169}) & (\num{7.169})\\ -drat & \num{40.961} & \num{40.961}\\ - & (\num{17.115}) & (\num{17.115})\\ -\midrule -Num.Obs. & \num{32} & \num{32}\\ -R2 & \num{0.759} & \num{0.759}\\ -R2 Adj. & \num{0.733} & \num{0.733}\\ -AIC & \num{324.9} & \num{324.9}\\ -BIC & \num{332.2} & \num{332.2}\\ -Log.Lik. & \num{-157.443} & \num{-157.443}\\ -RMSE & \num{33.15} & \num{33.15}\\ +& First\&Second & Third\_Fourth \\ \midrule %% TinyTableHeader +(Intercept) & \num{-103.772} & \num{-103.772} \\ +& (\num{103.551}) & (\num{103.551}) \\ +under\_score & \num{-3.899} & \num{-3.899} \\ +& (\num{2.072}) & (\num{2.072}) \\ +oh\&yeah2 & \num{29.329} & \num{29.329} \\ +& (\num{7.169}) & (\num{7.169}) \\ +drat & \num{40.961} & \num{40.961} \\ +& (\num{17.115}) & (\num{17.115}) \\ +Num.Obs. & \num{32} & \num{32} \\ +R2 & \num{0.759} & \num{0.759} \\ +R2 Adj. & \num{0.733} & \num{0.733} \\ +AIC & \num{324.9} & \num{324.9} \\ +BIC & \num{332.2} & \num{332.2} \\ +Log.Lik. & \num{-157.443} & \num{-157.443} \\ +RMSE & \num{33.15} & \num{33.15} \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/escape-modelsummary_html.txt b/inst/tinytest/_tinysnapshot/escape-modelsummary_html.txt index 217e08bb3..cc8c1194d 100644 --- a/inst/tinytest/_tinysnapshot/escape-modelsummary_html.txt +++ b/inst/tinytest/_tinysnapshot/escape-modelsummary_html.txt @@ -1,86 +1,221 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lm() lm_robust()
(Intercept) 10.790 10.790
(5.078) (3.626)
hp −0.052 −0.052
(0.009) (0.010)
drat 4.698 4.698
(1.192) (0.850)
Num.Obs. 32 32
R2 0.741 0.741
R2 Adj. 0.723 0.723
AIC 169.5 169.5
BIC 175.4 175.4
Log.Lik. −80.752 −80.752
F 41.522 41.153
RMSE 3.02 3.02
Std.Errors IID HC1
+ + + + + + tinytable + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
lm()lm_robust()
(Intercept)10.790 10.790
(5.078)(3.626)
hp -0.052 -0.052
(0.009)(0.010)
drat 4.698 4.698
(1.192)(0.850)
Num.Obs. 32 32
R2 0.741 0.741
R2 Adj. 0.723 0.723
AIC 169.5 169.5
BIC 175.4 175.4
Log.Lik. -80.752-80.752
F 41.522 41.153
RMSE 3.02 3.02
Std.Errors IID HC1
+
+ + + + + + + diff --git a/inst/tinytest/_tinysnapshot/escape-modelsummary_latex.txt b/inst/tinytest/_tinysnapshot/escape-modelsummary_latex.txt index 76294ede4..ca8874552 100644 --- a/inst/tinytest/_tinysnapshot/escape-modelsummary_latex.txt +++ b/inst/tinytest/_tinysnapshot/escape-modelsummary_latex.txt @@ -1,21 +1,28 @@ \begin{table} \centering -\begin{tabular}[t]{lccc} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=c,}, +column{3}={halign=c,}, +column{4}={halign=c,}, +hline{6}={1,2,3,4}{solid, 0.05em, black}, +} %% tabularray inner close \toprule - & (1) & (2) & (3)\\ -\midrule -disp\_x & \num{-0.041} & \num{-0.018} & \num{-0.018}\\ - & (\num{0.005}) & (\num{0.009}) & (\num{0.009})\\ -wt & & \num{-3.351} & \num{-3.279}\\ - & & (\num{1.164}) & (\num{1.328})\\ -\midrule -Num.Obs. & \num{32} & \num{32} & \num{32}\\ -R2 & \num{0.718} & \num{0.781} & \num{0.781}\\ -R2 Adj. & \num{0.709} & \num{0.766} & \num{0.758}\\ -AIC & \num{170.2} & \num{164.2} & \num{166.2}\\ -BIC & \num{174.6} & \num{170.0} & \num{173.5}\\ -Log.Lik. & \num{-82.105} & \num{-78.084} & \num{-78.076}\\ -RMSE & \num{3.15} & \num{2.78} & \num{2.78}\\ +& (1) & (2) & (3) \\ \midrule %% TinyTableHeader +disp\_x & \num{-0.041} & \num{-0.018} & \num{-0.018} \\ +& (\num{0.005}) & (\num{0.009}) & (\num{0.009}) \\ +wt & & \num{-3.351} & \num{-3.279} \\ +& & (\num{1.164}) & (\num{1.328}) \\ +Num.Obs. & \num{32} & \num{32} & \num{32} \\ +R2 & \num{0.718} & \num{0.781} & \num{0.781} \\ +R2 Adj. & \num{0.709} & \num{0.766} & \num{0.758} \\ +AIC & \num{170.2} & \num{164.2} & \num{166.2} \\ +BIC & \num{174.6} & \num{170.0} & \num{173.5} \\ +Log.Lik. & \num{-82.105} & \num{-78.084} & \num{-78.076} \\ +RMSE & \num{3.15} & \num{2.78} & \num{2.78} \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/escape-modelsummary_latex2.txt b/inst/tinytest/_tinysnapshot/escape-modelsummary_latex2.txt index 159ea8f3b..e9aeb9e45 100644 --- a/inst/tinytest/_tinysnapshot/escape-modelsummary_latex2.txt +++ b/inst/tinytest/_tinysnapshot/escape-modelsummary_latex2.txt @@ -1,21 +1,28 @@ \begin{table} \centering -\begin{tabular}[t]{lccc} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=c,}, +column{3}={halign=c,}, +column{4}={halign=c,}, +hline{6}={1,2,3,4}{solid, 0.05em, black}, +} %% tabularray inner close \toprule - & (1) & (2) & (3)\\ -\midrule -disp\_x & \num{-0.041} & \num{-0.018} & \num{-0.018}\\ - & (\num{0.005}) & (\num{0.009}) & (\num{0.009})\\ -wt\_x & & \num{-3.351} & \num{-3.279}\\ - & & (\num{1.164}) & (\num{1.328})\\ -\midrule -Num.Obs. & \num{32} & \num{32} & \num{32}\\ -R2 & \num{0.718} & \num{0.781} & \num{0.781}\\ -R2 Adj. & \num{0.709} & \num{0.766} & \num{0.758}\\ -AIC & \num{170.2} & \num{164.2} & \num{166.2}\\ -BIC & \num{174.6} & \num{170.0} & \num{173.5}\\ -Log.Lik. & \num{-82.105} & \num{-78.084} & \num{-78.076}\\ -RMSE & \num{3.15} & \num{2.78} & \num{2.78}\\ +& (1) & (2) & (3) \\ \midrule %% TinyTableHeader +disp\_x & \num{-0.041} & \num{-0.018} & \num{-0.018} \\ +& (\num{0.005}) & (\num{0.009}) & (\num{0.009}) \\ +wt\_x & & \num{-3.351} & \num{-3.279} \\ +& & (\num{1.164}) & (\num{1.328}) \\ +Num.Obs. & \num{32} & \num{32} & \num{32} \\ +R2 & \num{0.718} & \num{0.781} & \num{0.781} \\ +R2 Adj. & \num{0.709} & \num{0.766} & \num{0.758} \\ +AIC & \num{170.2} & \num{164.2} & \num{166.2} \\ +BIC & \num{174.6} & \num{170.0} & \num{173.5} \\ +Log.Lik. & \num{-82.105} & \num{-78.084} & \num{-78.076} \\ +RMSE & \num{3.15} & \num{2.78} & \num{2.78} \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/escape-panel_escape_TRUE.txt b/inst/tinytest/_tinysnapshot/escape-panel_escape_TRUE.txt index 6d6f16639..465f773e7 100644 --- a/inst/tinytest/_tinysnapshot/escape-panel_escape_TRUE.txt +++ b/inst/tinytest/_tinysnapshot/escape-panel_escape_TRUE.txt @@ -1,13 +1,13 @@ \begin{table} -\caption{\$\textbackslash{}beta\_1\$} +\caption{$\beta_1$} \centering \begin{tabular}[t]{lcc} \toprule - & A\_B & B\_C\\ + & A_B & B_C\\ \midrule \addlinespace[0.5em] -\multicolumn{3}{l}{\textit{Panel B: \$textbackslash{}log(3)textasciicircum{}2$}}\\ +\multicolumn{3}{l}{\textit{Panel B: $\log(3)^2$}}\\ \midrule \hspace{1em}(Intercept) & -5.114 & 48.324\\ \hspace{1em} & (10.030) & (11.103)\\ \hspace{1em}a_b & 1.412 & -0.887\\ @@ -22,7 +22,7 @@ \hspace{1em}Log.Lik. & -99.294 & -86.170\\ \hspace{1em}RMSE & 5.39 & 3.57\\ \addlinespace[0.5em] -\multicolumn{3}{l}{\textit{Panel B: \$textbackslash{}log(3)_2$}}\\ +\multicolumn{3}{l}{\textit{Panel B: $\log(3)_2$}}\\ \midrule \hspace{1em}(Intercept) & 767.619 & -340.780\\ \hspace{1em} & (204.642) & (221.689)\\ \hspace{1em}a_b & -30.080 & 17.599\\ diff --git a/inst/tinytest/_tinysnapshot/escape_label_title.txt b/inst/tinytest/_tinysnapshot/escape_label_title.txt index ce21eb0e6..3c6816556 100644 --- a/inst/tinytest/_tinysnapshot/escape_label_title.txt +++ b/inst/tinytest/_tinysnapshot/escape_label_title.txt @@ -1,23 +1,28 @@ \begin{table} +\caption{Blah_blah \label{tab:blah-blah}} \centering -\caption{Blah\_blah \label{tab:blah-blah}} -\begin{tabular}[t]{lc} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=c,}, +hline{6}={1,2}{solid, 0.05em, black}, +} %% tabularray inner close \toprule - & (1)\\ -\midrule -(Intercept) & \num{30.099}\\ - & (\num{1.634})\\ -hp & \num{-0.068}\\ - & (\num{0.010})\\ -\midrule -Num.Obs. & \num{32}\\ -R2 & \num{0.602}\\ -R2 Adj. & \num{0.589}\\ -AIC & \num{181.2}\\ -BIC & \num{185.6}\\ -Log.Lik. & \num{-87.619}\\ -F & \num{45.460}\\ -RMSE & \num{3.74}\\ +& (1) \\ \midrule %% TinyTableHeader +(Intercept) & \num{30.099} \\ +& (\num{1.634}) \\ +hp & \num{-0.068} \\ +& (\num{0.010}) \\ +Num.Obs. & \num{32} \\ +R2 & \num{0.602} \\ +R2 Adj. & \num{0.589} \\ +AIC & \num{181.2} \\ +BIC & \num{185.6} \\ +Log.Lik. & \num{-87.619} \\ +F & \num{45.460} \\ +RMSE & \num{3.74} \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/fmt-fmt_sci_2.txt b/inst/tinytest/_tinysnapshot/fmt-fmt_sci_2.txt index 59bf923bc..ed250e4a3 100644 --- a/inst/tinytest/_tinysnapshot/fmt-fmt_sci_2.txt +++ b/inst/tinytest/_tinysnapshot/fmt-fmt_sci_2.txt @@ -1,17 +1,32 @@ -| | (1) | -|:------------------|----------:| -| (Intercept) | 1.3e+21 | -| | (6.9e+20) | -| Year | -6.6e+17 | -| | (3.4e+17) | -| SD (Intercept ID) | 1.0e+18 | -| SD (Observations) | 2.3e+18 | -| Num.Obs. | 30 | -| R2 Marg. | 0.096 | -| R2 Cond. | 0.252 | -| AIC | 2466.3 | -| BIC | 2471.9 | -| ICC | 0.2 | -| RMSE | 2.1e+18 | ++-------------------+-----------+ +| | (1) | ++===================+===========+ +| (Intercept) | 1.3e+21 | ++-------------------+-----------+ +| | (6.9e+20) | ++-------------------+-----------+ +| Year | -6.6e+17 | ++-------------------+-----------+ +| | (3.4e+17) | ++-------------------+-----------+ +| SD (Intercept ID) | 1.0e+18 | ++-------------------+-----------+ +| SD (Observations) | 2.3e+18 | ++-------------------+-----------+ +| Num.Obs. | 30 | ++-------------------+-----------+ +| R2 Marg. | 0.096 | ++-------------------+-----------+ +| R2 Cond. | 0.252 | ++-------------------+-----------+ +| AIC | 2466.3 | ++-------------------+-----------+ +| BIC | 2471.9 | ++-------------------+-----------+ +| ICC | 0.2 | ++-------------------+-----------+ +| RMSE | 2.1e+18 | ++-------------------+-----------+ + diff --git a/inst/tinytest/_tinysnapshot/gt-background_color.txt b/inst/tinytest/_tinysnapshot/gt-background_color.txt new file mode 100644 index 000000000..9186748ae --- /dev/null +++ b/inst/tinytest/_tinysnapshot/gt-background_color.txt @@ -0,0 +1,140 @@ +< style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
colors
OLS 1Poisson 1OLS 2Logit 1Logit 2
(Intercept)349.2875.9721.34917.1001.403
(103.509)(0.105)(0.219)(10.843)(1.368)
mpg-9.417-0.078
(2.676)(0.004)
wt-4.168-0.072
(16.485)(0.087)
drat0.139-1.717
(0.038)(1.909)
hp-0.005-0.0890.122
(0.001)(0.039)(0.068)
disp-0.095
(0.048)
Num.Obs.3232323232
R20.6030.534
R2 Adj.0.5760.502
AIC338.8511.729.521.922.7
BIC344.6516.135.426.327.1
Log.Lik.-165.392-252.848-10.764-7.928-8.356
F22.053301.66716.6013.0132.617
RMSE42.5039.220.340.290.30
+ diff --git a/inst/tinytest/_tinysnapshot/gt-complex.txt b/inst/tinytest/_tinysnapshot/gt-complex.txt new file mode 100644 index 000000000..2ce3bd256 --- /dev/null +++ b/inst/tinytest/_tinysnapshot/gt-complex.txt @@ -0,0 +1,160 @@ +< style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Summarizing 5 statistical models using the `modelsummary` package for `R`.
Models estimated using the mtcars dataset.
+ Horsepower + + V-Shape + + Transmission +
OLS 1Poisson 1OLS 2Logit 1Logit 2
Horsepower-0.005***-0.089*0.122+
(0.001)(0.039)(0.068)
Miles/Gallon-9.417**-0.078***
(2.676)(0.004)
Weight-4.168-0.072
(16.485)(0.087)
Rear axle ratio0.139***-1.717
(0.038)(1.909)
Displacement-0.095*
(0.048)
Constant349.287**5.972***1.349***17.1001.403
(103.509)(0.105)(0.219)(10.843)(1.368)
Num.Obs.3232323232
R20.6030.534
R2 Adj.0.5760.502
AIC338.8511.729.521.922.7
BIC344.6516.135.426.327.1
F22.053301.66716.6013.0132.617
RMSE42.5039.220.340.290.30
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
First custom note to contain text.
Second custom note with different content.
+ diff --git a/inst/tinytest/_tinysnapshot/gt-title.txt b/inst/tinytest/_tinysnapshot/gt-title.txt new file mode 100644 index 000000000..75fddf55b --- /dev/null +++ b/inst/tinytest/_tinysnapshot/gt-title.txt @@ -0,0 +1,140 @@ +< style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
This is a title for my table.
OLS 1Poisson 1OLS 2Logit 1Logit 2
(Intercept)349.2875.9721.34917.1001.403
(103.509)(0.105)(0.219)(10.843)(1.368)
mpg-9.417-0.078
(2.676)(0.004)
wt-4.168-0.072
(16.485)(0.087)
drat0.139-1.717
(0.038)(1.909)
hp-0.005-0.0890.122
(0.001)(0.039)(0.068)
disp-0.095
(0.048)
Num.Obs.3232323232
R20.6030.534
R2 Adj.0.5760.502
AIC338.8511.729.521.922.7
BIC344.6516.135.426.327.1
Log.Lik.-165.392-252.848-10.764-7.928-8.356
F22.053301.66716.6013.0132.617
RMSE42.5039.220.340.290.30
+ diff --git a/inst/tinytest/_tinysnapshot/html-gof_omit.txt b/inst/tinytest/_tinysnapshot/html-gof_omit.txt index 61135a624..d24802000 100644 --- a/inst/tinytest/_tinysnapshot/html-gof_omit.txt +++ b/inst/tinytest/_tinysnapshot/html-gof_omit.txt @@ -1,26 +1,118 @@ - - - - - - - - - - - - - - - - - - - - - - - - - -
 (1)
(Intercept) 324.082
(27.433)
mpg −8.830
(1.310)
+ + + + + + tinytable + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
(1)
(Intercept)324.082
(27.433)
mpg -8.830
(1.310)
+
+ + + + + + + diff --git a/inst/tinytest/_tinysnapshot/interaction-markdown.txt b/inst/tinytest/_tinysnapshot/interaction-markdown.txt index 93ffdf5e5..ace3fbef6 100644 --- a/inst/tinytest/_tinysnapshot/interaction-markdown.txt +++ b/inst/tinytest/_tinysnapshot/interaction-markdown.txt @@ -1,28 +1,54 @@ -| | (1) | -|:----------------|--------:| -| (Intercept) | -2.956 | -| | (2.466) | -| drat | 0.884 | -| | (0.712) | -| mpg | 0.039 | -| | (0.139) | -| vs | 0.189 | -| | (4.317) | -| drat × mpg | -0.006 | -| | (0.038) | -| drat × vs | -0.404 | -| | (1.149) | -| mpg × vs | 0.054 | -| | (0.207) | -| drat × mpg × vs | -0.003 | -| | (0.054) | -| Num.Obs. | 32 | -| R2 | 0.662 | -| R2 Adj. | 0.563 | -| AIC | 28.6 | -| BIC | 41.8 | -| Log.Lik. | -5.298 | -| F | 6.715 | -| RMSE | 0.29 | ++-----------------+---------+ +| | (1) | ++=================+=========+ +| (Intercept) | -2.956 | ++-----------------+---------+ +| | (2.466) | ++-----------------+---------+ +| drat | 0.884 | ++-----------------+---------+ +| | (0.712) | ++-----------------+---------+ +| mpg | 0.039 | ++-----------------+---------+ +| | (0.139) | ++-----------------+---------+ +| vs | 0.189 | ++-----------------+---------+ +| | (4.317) | ++-----------------+---------+ +| drat × mpg | -0.006 | ++-----------------+---------+ +| | (0.038) | ++-----------------+---------+ +| drat × vs | -0.404 | ++-----------------+---------+ +| | (1.149) | ++-----------------+---------+ +| mpg × vs | 0.054 | ++-----------------+---------+ +| | (0.207) | ++-----------------+---------+ +| drat × mpg × vs | -0.003 | ++-----------------+---------+ +| | (0.054) | ++-----------------+---------+ +| Num.Obs. | 32 | ++-----------------+---------+ +| R2 | 0.662 | ++-----------------+---------+ +| R2 Adj. | 0.563 | ++-----------------+---------+ +| AIC | 28.6 | ++-----------------+---------+ +| BIC | 41.8 | ++-----------------+---------+ +| Log.Lik. | -5.298 | ++-----------------+---------+ +| F | 6.715 | ++-----------------+---------+ +| RMSE | 0.29 | ++-----------------+---------+ + diff --git a/inst/tinytest/_tinysnapshot/interaction-markdown_no_gof.txt b/inst/tinytest/_tinysnapshot/interaction-markdown_no_gof.txt index 9afc66d41..7d364ee1b 100644 --- a/inst/tinytest/_tinysnapshot/interaction-markdown_no_gof.txt +++ b/inst/tinytest/_tinysnapshot/interaction-markdown_no_gof.txt @@ -1,16 +1,30 @@ -| | (1) | -|:------------|---------:| -| (Intercept) | 3.219 | -| | (7.919) | -| Solar.R | 0.115 | -| | (0.030) | -| Month = 6 | 5.069 | -| | (10.980) | -| Month = 7 | 31.042 | -| | (8.018) | -| Month = 8 | 36.903 | -| | (8.201) | -| Month = 9 | 8.912 | -| | (7.763) | ++-------------+----------+ +| | (1) | ++=============+==========+ +| (Intercept) | 3.219 | ++-------------+----------+ +| | (7.919) | ++-------------+----------+ +| Solar.R | 0.115 | ++-------------+----------+ +| | (0.030) | ++-------------+----------+ +| Month = 6 | 5.069 | ++-------------+----------+ +| | (10.980) | ++-------------+----------+ +| Month = 7 | 31.042 | ++-------------+----------+ +| | (8.018) | ++-------------+----------+ +| Month = 8 | 36.903 | ++-------------+----------+ +| | (8.201) | ++-------------+----------+ +| Month = 9 | 8.912 | ++-------------+----------+ +| | (7.763) | ++-------------+----------+ + diff --git a/inst/tinytest/_tinysnapshot/kableExtra-markdown_complex.txt b/inst/tinytest/_tinysnapshot/kableExtra-markdown_complex.txt index 4b95fb5b2..428231b7d 100644 --- a/inst/tinytest/_tinysnapshot/kableExtra-markdown_complex.txt +++ b/inst/tinytest/_tinysnapshot/kableExtra-markdown_complex.txt @@ -1,34 +1,34 @@ - Table: Summarizing 5 statistical models using the `modelsummary` package for `R`. +Table: Summarizing 5 statistical models using the `modelsummary` package for `R`. -| | OLS 1 | Poisson 1 | OLS 2 | Logit 1 | Logit 2 | -|:----------------|----------:|----------:|----------:|---------:|--------:| -| Horsepower | | | -0.005*** | -0.089* | 0.122+ | -| | | | (0.001) | (0.039) | (0.068) | -| Miles/Gallon | -9.417** | -0.078*** | | | | -| | (2.676) | (0.004) | | | | -| Weight | -4.168 | | -0.072 | | | -| | (16.485) | | (0.087) | | | -| Rear axle ratio | | 0.139*** | | -1.717 | | -| | | (0.038) | | (1.909) | | -| Displacement | | | | | -0.095* | -| | | | | | (0.048) | -| Constant | 349.287** | 5.972*** | 1.349*** | 17.100 | 1.403 | -| | (103.509) | (0.105) | (0.219) | (10.843) | (1.368) | -| Num.Obs. | 32 | 32 | 32 | 32 | 32 | -| R2 | 0.603 | | 0.534 | | | -| R2 Adj. | 0.576 | | 0.502 | | | -| AIC | 338.8 | 511.7 | 29.5 | 21.9 | 22.7 | -| BIC | 344.6 | 516.1 | 35.4 | 26.3 | 27.1 | -| F | 22.053 | 301.667 | 16.601 | 3.013 | 2.617 | -| RMSE | 42.50 | 39.22 | 0.34 | 0.29 | 0.30 | +| | OLS 1 | Poisson 1 | OLS 2 | Logit 1 | Logit 2 | +|:---------------|:---------:|:---------:|:---------:|:--------:|:-------:| +|Horsepower | | | -0.005*** | -0.089* | 0.122+ | +| | | | (0.001) | (0.039) | (0.068) | +|Miles/Gallon | -9.417** | -0.078*** | | | | +| | (2.676) | (0.004) | | | | +|Weight | -4.168 | | -0.072 | | | +| | (16.485) | | (0.087) | | | +|Rear axle ratio | | 0.139*** | | -1.717 | | +| | | (0.038) | | (1.909) | | +|Displacement | | | | | -0.095* | +| | | | | | (0.048) | +|Constant | 349.287** | 5.972*** | 1.349*** | 17.100 | 1.403 | +| | (103.509) | (0.105) | (0.219) | (10.843) | (1.368) | +|Num.Obs. | 32 | 32 | 32 | 32 | 32 | +|R2 | 0.603 | | 0.534 | | | +|R2 Adj. | 0.576 | | 0.502 | | | +|AIC | 338.8 | 511.7 | 29.5 | 21.9 | 22.7 | +|BIC | 344.6 | 516.1 | 35.4 | 26.3 | 27.1 | +|F | 22.053 | 301.667 | 16.601 | 3.013 | 2.617 | +|RMSE | 42.50 | 39.22 | 0.34 | 0.29 | 0.30 | __Note:__ -^^ + p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001 ++ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001 __Note:__ -^^ First custom note to contain text. +First custom note to contain text. __Note:__ -^^ Second custom note with different content. +Second custom note with different content. diff --git a/inst/tinytest/_tinysnapshot/kableExtra-markdown_fmt.txt b/inst/tinytest/_tinysnapshot/kableExtra-markdown_fmt.txt index 6ca5c7a06..5aea87cec 100644 --- a/inst/tinytest/_tinysnapshot/kableExtra-markdown_fmt.txt +++ b/inst/tinytest/_tinysnapshot/kableExtra-markdown_fmt.txt @@ -1,27 +1,27 @@ -| | OLS 1 | Poisson 1 | OLS 2 | Logit 1 | Logit 2 | -|:------------|---------------:|-------------:|-------------:|--------------:|-------------:| -| (Intercept) | 349.28734855* | 5.97181727* | 1.34867726* | 17.09975551 | 1.40342203 | -| | (103.50934696) | (0.10521726) | (0.21935248) | (10.84261865) | (1.36756660) | -| mpg | -9.41684544* | -0.07770591* | | | | -| | (2.67621950) | (0.00368319) | | | | -| wt | -4.16801248 | | -0.07150616 | | | -| | (16.48455540) | | (0.08681057) | | | -| drat | | 0.13881387* | | -1.71683105 | | -| | | (0.03805311) | | (1.90934366) | | -| hp | | | -0.00464337* | -0.08901954+ | 0.12170173+ | -| | | | (0.00123887) | (0.03933000) | (0.06777320) | -| disp | | | | | -0.09517972+ | -| | | | | | (0.04800283) | -| Num.Obs. | 32 | 32 | 32 | 32 | 32 | -| R2 | 0.603 | | 0.534 | | | -| R2 Adj. | 0.576 | | 0.502 | | | -| AIC | 338.8 | 511.7 | 29.5 | 21.9 | 22.7 | -| BIC | 344.6 | 516.1 | 35.4 | 26.3 | 27.1 | -| Log.Lik. | -165.392 | -252.848 | -10.764 | -7.928 | -8.356 | -| F | 22.053 | 301.667 | 16.601 | 3.013 | 2.617 | -| RMSE | 42.50 | 39.22 | 0.34 | 0.29 | 0.30 | +| | OLS 1 | Poisson 1 | OLS 2 | Logit 1 | Logit 2 | +|:-----------|:--------------:|:------------:|:------------:|:-------------:|:------------:| +|(Intercept) | 349.28734855* | 5.97181727* | 1.34867726* | 17.09975551 | 1.40342203 | +| | (103.50934696) | (0.10521726) | (0.21935248) | (10.84261865) | (1.36756660) | +|mpg | -9.41684544* | -0.07770591* | | | | +| | (2.67621950) | (0.00368319) | | | | +|wt | -4.16801248 | | -0.07150616 | | | +| | (16.48455540) | | (0.08681057) | | | +|drat | | 0.13881387* | | -1.71683105 | | +| | | (0.03805311) | | (1.90934366) | | +|hp | | | -0.00464337* | -0.08901954+ | 0.12170173+ | +| | | | (0.00123887) | (0.03933000) | (0.06777320) | +|disp | | | | | -0.09517972+ | +| | | | | | (0.04800283) | +|Num.Obs. | 32 | 32 | 32 | 32 | 32 | +|R2 | 0.603 | | 0.534 | | | +|R2 Adj. | 0.576 | | 0.502 | | | +|AIC | 338.8 | 511.7 | 29.5 | 21.9 | 22.7 | +|BIC | 344.6 | 516.1 | 35.4 | 26.3 | 27.1 | +|Log.Lik. | -165.392 | -252.848 | -10.764 | -7.928 | -8.356 | +|F | 22.053 | 301.667 | 16.601 | 3.013 | 2.617 | +|RMSE | 42.50 | 39.22 | 0.34 | 0.29 | 0.30 | __Note:__ -^^ + p < 0.1, * p < 0.01 ++ p < 0.1, * p < 0.01 diff --git a/inst/tinytest/_tinysnapshot/pkg-fixest_model_names_single.txt b/inst/tinytest/_tinysnapshot/pkg-fixest_model_names_single.txt new file mode 100644 index 000000000..f1f5030cb --- /dev/null +++ b/inst/tinytest/_tinysnapshot/pkg-fixest_model_names_single.txt @@ -0,0 +1,28 @@ + + ++-------------+---------+---------+ +| | A | K | ++=============+=========+=========+ +| (Intercept) | 4.778 | 4.778 | ++-------------+---------+---------+ +| | (0.073) | (0.073) | ++-------------+---------+---------+ +| x1 | 0.889 | 0.889 | ++-------------+---------+---------+ +| | (0.051) | (0.051) | ++-------------+---------+---------+ +| Num.Obs. | 150 | 150 | ++-------------+---------+---------+ +| R2 | 0.669 | 0.669 | ++-------------+---------+---------+ +| R2 Adj. | 0.667 | 0.667 | ++-------------+---------+---------+ +| AIC | 206.2 | 206.2 | ++-------------+---------+---------+ +| BIC | 212.2 | 212.2 | ++-------------+---------+---------+ +| RMSE | 0.47 | 0.47 | ++-------------+---------+---------+ +| Std.Errors | IID | IID | ++-------------+---------+---------+ + diff --git a/inst/tinytest/_tinysnapshot/rbind-add_rows_rbind.txt b/inst/tinytest/_tinysnapshot/rbind-add_rows_rbind.txt index a550f1b18..b43e77c6e 100644 --- a/inst/tinytest/_tinysnapshot/rbind-add_rows_rbind.txt +++ b/inst/tinytest/_tinysnapshot/rbind-add_rows_rbind.txt @@ -1,21 +1,36 @@ -| | (1) | (2) | -|:------------|--------:|--------:| -| (Intercept) | 20.09 | -5.11 | -| | (1.07) | (10.03) | -| qsec | | 1.41 | -| | | (0.56) | -| R2 | 0.000 | 0.175 | -| Info | ??? | XYZ | -| Num.Obs. | 32 | 32 | -| RMSE | 5.93 | 5.39 | -|:------------|--------:|--------:| -| (Intercept) | 146.69 | 631.70 | -| | (12.12) | (88.70) | -| qsec | | -27.17 | -| | | (4.95) | -| R2 | 0.000 | 0.502 | -| Num.Obs. | 32 | 32 | -| RMSE | 67.48 | 47.64 | -|:------------|--------:|--------:| ++-------------+---------+---------+ +| | (1) | (2) | ++=============+=========+=========+ +| (Intercept) | 20.09 | -5.11 | ++-------------+---------+---------+ +| | (1.07) | (10.03) | ++-------------+---------+---------+ +| qsec | | 1.41 | ++-------------+---------+---------+ +| | | (0.56) | ++-------------+---------+---------+ +| R2 | 0.000 | 0.175 | ++-------------+---------+---------+ +| Info | ??? | XYZ | ++-------------+---------+---------+ +| Num.Obs. | 32 | 32 | ++-------------+---------+---------+ +| RMSE | 5.93 | 5.39 | ++-------------+---------+---------+ +| (Intercept) | 146.69 | 631.70 | ++-------------+---------+---------+ +| | (12.12) | (88.70) | ++-------------+---------+---------+ +| qsec | | -27.17 | ++-------------+---------+---------+ +| | | (4.95) | ++-------------+---------+---------+ +| R2 | 0.000 | 0.502 | ++-------------+---------+---------+ +| Num.Obs. | 32 | 32 | ++-------------+---------+---------+ +| RMSE | 67.48 | 47.64 | ++-------------+---------+---------+ + diff --git a/inst/tinytest/_tinysnapshot/rounding-datasummary_latex.txt b/inst/tinytest/_tinysnapshot/rounding-datasummary_latex.txt index 7390bbe43..cbd7fe600 100644 --- a/inst/tinytest/_tinysnapshot/rounding-datasummary_latex.txt +++ b/inst/tinytest/_tinysnapshot/rounding-datasummary_latex.txt @@ -1,13 +1,19 @@ \begin{table} \centering -\begin{tabular}[t]{lrr} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=r,}, +column{3}={halign=r,}, +} %% tabularray inner close \toprule -cyl & SD & N\\ -\midrule -4 & & 11\\ -6 & & 7\\ -8 & & 14\\ -mpg & \num{6.03} & 32\\ +cyl & SD & N \\ \midrule %% TinyTableHeader +4 & & 11 \\ +6 & & 7 \\ +8 & & 14 \\ +mpg & \num{6.03} & 32 \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/shape-multinom_wide.txt b/inst/tinytest/_tinysnapshot/shape-multinom_wide.txt index b3ded153a..df12fdd05 100644 --- a/inst/tinytest/_tinysnapshot/shape-multinom_wide.txt +++ b/inst/tinytest/_tinysnapshot/shape-multinom_wide.txt @@ -1,18 +1,29 @@ \begin{table} \centering -\begin{tabular}[t]{lcccc} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]Q[]Q[]}, +cell{1}{1}={c=1,}{halign=c,}, +cell{1}{2}={c=2,}{halign=c,}, +cell{1}{4}={c=2,}{halign=c,}, +column{1}={halign=l,}, +column{2}={halign=c,}, +column{3}={halign=c,}, +column{4}={halign=c,}, +column{5}={halign=c,}, +row{1}={halign=c,}, +hline{5}={1,2,3,4,5}{solid, 0.05em, black}, +} %% tabularray inner close \toprule -\multicolumn{1}{c}{ } & \multicolumn{2}{c}{a} & \multicolumn{2}{c}{b} \\ -\cmidrule(l{3pt}r{3pt}){2-3} \cmidrule(l{3pt}r{3pt}){4-5} - & 6 & 8 & 6 & 8\\ -\midrule -Under Score & \num{-2.205} & \num{-3.580} & \num{-3.627} & \num{-4.838}\\ - & (\num{1.638}) & (\num{1.775}) & (\num{3.869}) & (\num{3.915})\\ -\midrule -Num.Obs. & \num{32} & & \num{32} & \\ -AIC & \num{24.1} & & \num{24.5} & \\ -BIC & \num{30.0} & & \num{33.3} & \\ -RMSE & \num{0.24} & & \num{0.20} & \\ +& a & & b & \\ \cmidrule[lr]{1-1}\cmidrule[lr]{2-3}\cmidrule[lr]{4-5} +& 6 & 8 & 6 & 8 \\ \midrule %% TinyTableHeader +Under Score & \num{-2.205} & \num{-3.580} & \num{-3.627} & \num{-4.838} \\ +& (\num{1.638}) & (\num{1.775}) & (\num{3.869}) & (\num{3.915}) \\ +Num.Obs. & \num{32} & & \num{32} & \\ +AIC & \num{24.1} & & \num{24.5} & \\ +BIC & \num{30.0} & & \num{33.3} & \\ +RMSE & \num{0.24} & & \num{0.20} & \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/_tinysnapshot/test-pkg-fixest_model_names_single.txt b/inst/tinytest/_tinysnapshot/test-pkg-fixest_model_names_single.txt deleted file mode 100644 index ffd2349aa..000000000 --- a/inst/tinytest/_tinysnapshot/test-pkg-fixest_model_names_single.txt +++ /dev/null @@ -1,15 +0,0 @@ - - -| | A | K | -|:------------|--------:|--------:| -| (Intercept) | 4.778 | 4.778 | -| | (0.073) | (0.073) | -| x1 | 0.889 | 0.889 | -| | (0.051) | (0.051) | -| Num.Obs. | 150 | 150 | -| R2 | 0.669 | 0.669 | -| R2 Adj. | 0.667 | 0.667 | -| AIC | 206.2 | 206.2 | -| BIC | 212.2 | 212.2 | -| RMSE | 0.47 | 0.47 | -| Std.Errors | IID | IID | diff --git a/inst/tinytest/helpers.R b/inst/tinytest/helpers.R index ff8b25ebb..ec6f49ca4 100644 --- a/inst/tinytest/helpers.R +++ b/inst/tinytest/helpers.R @@ -1,5 +1,5 @@ rm(list = ls()) -modelsummary::config_modelsummary(reset = TRUE) +suppressWarnings(modelsummary::config_modelsummary(reset = TRUE)) ON_CRAN <- !identical(Sys.getenv("R_NOT_CRAN"), "true") ON_GH <- identical(Sys.getenv("R_GH"), "true") @@ -23,6 +23,27 @@ compare_files <- function(x, y) { expect_equivalent(known, unknown) } +print.custom_html_string <- function(x, ...) { + cat(x, "\n", sep = "", ...) + invisible(x) +} + + +print_html <- function(x) { + if (inherits(x, "tinytable")) { + x <- tinytable::save_tt(x, output = "html") + x <- gsub("tinytable_\\w+\\b", "tinytable", x) + x <- gsub("styleCell_\\w+\\b", "tinytable", x) + x <- gsub("insertSpanRow\\w+\\b", "tinytable", x) + x <- gsub("styleHeaderCell_\\w+\\b", "tinytable", x) + } else if (inherits(x, "gt_tbl")) { + x <- gt::as_raw_html(x) + x <- gsub('div id="\\w+"', '', x) + } + class(x) <- c("custom_html_string", "character") + return(x) +} + requiet("tinytest") requiet("tinysnapshot") diff --git a/inst/tinytest/known_output/output-file.md b/inst/tinytest/known_output/output-file.md index f93798b70..e1b1b5322 100644 --- a/inst/tinytest/known_output/output-file.md +++ b/inst/tinytest/known_output/output-file.md @@ -1,16 +1,34 @@ -| | (1) | (2) | -|:------------|---------:|---------:| -| (Intercept) | 324.082 | 278.515 | -| | (27.433) | (55.415) | -| mpg | -8.830 | -9.985 | -| | (1.310) | (1.792) | -| drat | | 19.126 | -| | | (20.198) | -| Num.Obs. | 32 | 32 | -| R2 | 0.602 | 0.614 | -| R2 Adj. | 0.589 | 0.588 | -| AIC | 336.9 | 337.9 | -| BIC | 341.3 | 343.7 | -| Log.Lik. | -165.428 | -164.940 | -| F | 45.460 | 23.100 | -| RMSE | 42.55 | 41.91 | + + ++-------------+----------+----------+ +| | (1) | (2) | ++=============+==========+==========+ +| (Intercept) | 324.082 | 278.515 | ++-------------+----------+----------+ +| | (27.433) | (55.415) | ++-------------+----------+----------+ +| mpg | -8.830 | -9.985 | ++-------------+----------+----------+ +| | (1.310) | (1.792) | ++-------------+----------+----------+ +| drat | | 19.126 | ++-------------+----------+----------+ +| | | (20.198) | ++-------------+----------+----------+ +| Num.Obs. | 32 | 32 | ++-------------+----------+----------+ +| R2 | 0.602 | 0.614 | ++-------------+----------+----------+ +| R2 Adj. | 0.589 | 0.588 | ++-------------+----------+----------+ +| AIC | 336.9 | 337.9 | ++-------------+----------+----------+ +| BIC | 341.3 | 343.7 | ++-------------+----------+----------+ +| Log.Lik. | -165.428 | -164.940 | ++-------------+----------+----------+ +| F | 45.460 | 23.100 | ++-------------+----------+----------+ +| RMSE | 42.55 | 41.91 | ++-------------+----------+----------+ + diff --git a/inst/tinytest/known_output/output-file.tex b/inst/tinytest/known_output/output-file.tex index c676dcdd8..a82a11243 100644 --- a/inst/tinytest/known_output/output-file.tex +++ b/inst/tinytest/known_output/output-file.tex @@ -1,24 +1,30 @@ \begin{table} \centering -\begin{tabular}[t]{lcc} +\begin{tblr}[ %% tabularray outer open +] %% tabularray outer close +{ %% tabularray inner open +colspec={Q[]Q[]Q[]}, +column{1}={halign=l,}, +column{2}={halign=c,}, +column{3}={halign=c,}, +hline{8}={1,2,3}{solid, 0.05em, black}, +} %% tabularray inner close \toprule - & (1) & (2)\\ -\midrule -(Intercept) & \num{324.082} & \num{278.515}\\ - & (\num{27.433}) & (\num{55.415})\\ -mpg & \num{-8.830} & \num{-9.985}\\ - & (\num{1.310}) & (\num{1.792})\\ -drat & & \num{19.126}\\ - & & (\num{20.198})\\ -\midrule -Num.Obs. & \num{32} & \num{32}\\ -R2 & \num{0.602} & \num{0.614}\\ -R2 Adj. & \num{0.589} & \num{0.588}\\ -AIC & \num{336.9} & \num{337.9}\\ -BIC & \num{341.3} & \num{343.7}\\ -Log.Lik. & \num{-165.428} & \num{-164.940}\\ -F & \num{45.460} & \num{23.100}\\ -RMSE & \num{42.55} & \num{41.91}\\ +& (1) & (2) \\ \midrule %% TinyTableHeader +(Intercept) & \num{324.082} & \num{278.515} \\ +& (\num{27.433}) & (\num{55.415}) \\ +mpg & \num{-8.830} & \num{-9.985} \\ +& (\num{1.310}) & (\num{1.792}) \\ +drat & & \num{19.126} \\ +& & (\num{20.198}) \\ +Num.Obs. & \num{32} & \num{32} \\ +R2 & \num{0.602} & \num{0.614} \\ +R2 Adj. & \num{0.589} & \num{0.588} \\ +AIC & \num{336.9} & \num{337.9} \\ +BIC & \num{341.3} & \num{343.7} \\ +Log.Lik. & \num{-165.428} & \num{-164.940} \\ +F & \num{45.460} & \num{23.100} \\ +RMSE & \num{42.55} & \num{41.91} \\ \bottomrule -\end{tabular} +\end{tblr} \end{table} diff --git a/inst/tinytest/known_output/output-file.txt b/inst/tinytest/known_output/output-file.txt index f93798b70..e1b1b5322 100644 --- a/inst/tinytest/known_output/output-file.txt +++ b/inst/tinytest/known_output/output-file.txt @@ -1,16 +1,34 @@ -| | (1) | (2) | -|:------------|---------:|---------:| -| (Intercept) | 324.082 | 278.515 | -| | (27.433) | (55.415) | -| mpg | -8.830 | -9.985 | -| | (1.310) | (1.792) | -| drat | | 19.126 | -| | | (20.198) | -| Num.Obs. | 32 | 32 | -| R2 | 0.602 | 0.614 | -| R2 Adj. | 0.589 | 0.588 | -| AIC | 336.9 | 337.9 | -| BIC | 341.3 | 343.7 | -| Log.Lik. | -165.428 | -164.940 | -| F | 45.460 | 23.100 | -| RMSE | 42.55 | 41.91 | + + ++-------------+----------+----------+ +| | (1) | (2) | ++=============+==========+==========+ +| (Intercept) | 324.082 | 278.515 | ++-------------+----------+----------+ +| | (27.433) | (55.415) | ++-------------+----------+----------+ +| mpg | -8.830 | -9.985 | ++-------------+----------+----------+ +| | (1.310) | (1.792) | ++-------------+----------+----------+ +| drat | | 19.126 | ++-------------+----------+----------+ +| | | (20.198) | ++-------------+----------+----------+ +| Num.Obs. | 32 | 32 | ++-------------+----------+----------+ +| R2 | 0.602 | 0.614 | ++-------------+----------+----------+ +| R2 Adj. | 0.589 | 0.588 | ++-------------+----------+----------+ +| AIC | 336.9 | 337.9 | ++-------------+----------+----------+ +| BIC | 341.3 | 343.7 | ++-------------+----------+----------+ +| Log.Lik. | -165.428 | -164.940 | ++-------------+----------+----------+ +| F | 45.460 | 23.100 | ++-------------+----------+----------+ +| RMSE | 42.55 | 41.91 | ++-------------+----------+----------+ + diff --git a/inst/tinytest/test-conf_level.R b/inst/tinytest/test-conf_level.R index 809d6127e..f30c60658 100644 --- a/inst/tinytest/test-conf_level.R +++ b/inst/tinytest/test-conf_level.R @@ -1,4 +1,4 @@ -exit_file("works interactively") +# exit_file("works interactively") # Issue 513 # bad combination of arguments @@ -21,7 +21,7 @@ expect_true(any(grepl("\\[", tab[["(1)"]]))) # faster est <- get_estimates(mod, conf_level = NULL) -expect_false("conf.low" %in% colnames(est)) +expect_true(!"conf.low" %in% colnames(est) || all(is.na(est$conf.low))) ci_funs <- paste0(c("^ci$", "ci\\.glm", "confint\\.glm", "stats::confint"), collapse = "|") mod <- list() @@ -30,7 +30,7 @@ mod$Logit <- glm(am ~ qsec, data = mtcars, family = poisson()) # when confidence intervals are enabled, some CI functions should have been called", tmp_withCI <- tempfile() -Rprof(tmp_withCI, interval = 0.005) +suppressWarnings(Rprof(tmp_withCI, interval = 0.005)) tab <- modelsummary(mod, output = "data.frame", statistic = "conf.int", @@ -42,7 +42,7 @@ expect_true(any(grepl(ci_funs, called_funs))) # when no confidence intervals are needed, no CI functions should have been called tmp_withoutCI <- tempfile() -Rprof(tmp_withoutCI, interval = 0.005) +suppressWarnings(Rprof(tmp_withoutCI, interval = 0.005)) tmp <- modelsummary(mod, output = "data.frame", statistic = NULL, vcov = NULL, conf_level = NULL, diff --git a/inst/tinytest/test-datasummary.R b/inst/tinytest/test-datasummary.R index b8efbf986..54273c9ba 100644 --- a/inst/tinytest/test-datasummary.R +++ b/inst/tinytest/test-datasummary.R @@ -133,6 +133,6 @@ expect_true(is.numeric(tmp$male)) url <- "https://vincentarelbundock.github.io/Rdatasets/csv/palmerpenguins/penguins.csv" penguins <- read.csv(url, na.strings = "") tab <- datasummary(island * species * body_mass_g ~ sex * (Mean + SD), data = penguins) -expect_inherits(tab, "kableExtra") +expect_inherits(tab, "tinytable") tab <- datasummary(island * species * body_mass_g ~ sex * (Mean + SD) * DropEmpty(), data = penguins) -expect_inherits(tab, "kableExtra") \ No newline at end of file +expect_inherits(tab, "tinytable") \ No newline at end of file diff --git a/inst/tinytest/test-datasummary_balance.R b/inst/tinytest/test-datasummary_balance.R index 96bbba763..78306995d 100644 --- a/inst/tinytest/test-datasummary_balance.R +++ b/inst/tinytest/test-datasummary_balance.R @@ -11,7 +11,7 @@ expect_snapshot_print( "datasummary_balance-escape_TRUE") expect_snapshot_print( datasummary_balance(~vs, data = dat, output = "latex", escape = FALSE), - "datasummary_balance-escape_TRUE") + "datasummary_balance-escape_FALSE") # stub is escaped in latex tmp <- data.frame( @@ -65,10 +65,12 @@ tab <- datasummary_balance(~vs, dat, output="dataframe") expect_equivalent(tab[[4]][1:2], c("5.6", "16.7")) # palmer penguins was once broken with kableExtra +options(modelsummary_factory_html = "kableExtra") penguins <- "https://vincentarelbundock.github.io/Rdatasets/csv/palmerpenguins/penguins.csv" penguins <- read.csv(penguins) raw <- datasummary_balance(~sex, penguins, output = "html", dinm = FALSE) expect_inherits(raw, "knitr_kable") +options(modelsummary_factory_html = NULL) # variable name with spaces tmp <- mtcars diff --git a/inst/tinytest/test-datasummary_crosstab.R b/inst/tinytest/test-datasummary_crosstab.R index 52bb2b1d0..a71088b5f 100644 --- a/inst/tinytest/test-datasummary_crosstab.R +++ b/inst/tinytest/test-datasummary_crosstab.R @@ -93,6 +93,6 @@ expect_equivalent(dim(tab3), c(14, 10)) dat <- mtcars dat$`# of Cylinders` <- dat$cyl tab <- datasummary_crosstab(`# of Cylinders` ~ am * gear, data = dat) -expect_inherits(tab, "kableExtra") +expect_inherits(tab, "tinytable") expect_error(datasummary_crosstab((`# of Cylinders` = cyl) ~ am * gear, data = dat)) expect_error(datasummary_crosstab(Heading("# of Cylinders") * cyl ~ am * gear, data = dat)) \ No newline at end of file diff --git a/inst/tinytest/test-datasummary_df.R b/inst/tinytest/test-datasummary_df.R index 2ff7b9ec0..dd333665d 100644 --- a/inst/tinytest/test-datasummary_df.R +++ b/inst/tinytest/test-datasummary_df.R @@ -1,4 +1,6 @@ -# TODO: add_columns +source("helpers.R") + +exit_file("tinytable must support multiple notes in Markdown") tmp <- head(mtcars) @@ -17,4 +19,4 @@ tab <- datasummary_df( title = "blah blah title", notes = c("first note", "second note"), add_rows = ar) -expect_inherits(tab, "kableExtra") \ No newline at end of file +expect_inherits(tab, "tinytable") \ No newline at end of file diff --git a/inst/tinytest/test-datasummary_skim.R b/inst/tinytest/test-datasummary_skim.R index d4d2c6347..52acf1e31 100644 --- a/inst/tinytest/test-datasummary_skim.R +++ b/inst/tinytest/test-datasummary_skim.R @@ -104,7 +104,7 @@ expect_equivalent(dim(tab), c(4, 2)) penguins <- read.csv("https://vincentarelbundock.github.io/Rdatasets/csv/palmerpenguins/penguins.csv") penguins <- tibble::as_tibble(penguins) tab <- datasummary_skim(penguins) -expect_inherits(tab, "kableExtra") +expect_inherits(tab, "tinytable") # Issue #627: histograms in gt diff --git a/inst/tinytest/test-deprecated.R b/inst/tinytest/test-deprecated.R deleted file mode 100644 index ec5f067b1..000000000 --- a/inst/tinytest/test-deprecated.R +++ /dev/null @@ -1,17 +0,0 @@ -mod <- lm(hp ~ mpg, mtcars) - -# hard deprecation -expect_warning( - modelsummary(mod, statistic_vertical = TRUE), - pattern = "deprecated") -expect_warning( - modelsummary(mod, statistic_vertical = FALSE), - pattern = "deprecated") - -# soft deprecation -tab1 = modelsummary(mod, statistic_override = "robust") -tab2 = modelsummary(mod, vcov = "robust") -expect_identical(tab1, tab2) -expect_error( - modelsummary(mod, vcov = "robust", statistic_override = "robust"), - pattern = "deprecated") \ No newline at end of file diff --git a/inst/tinytest/test-escape.R b/inst/tinytest/test-escape.R index ae0cb0cb6..159434093 100644 --- a/inst/tinytest/test-escape.R +++ b/inst/tinytest/test-escape.R @@ -1,6 +1,7 @@ source("helpers.R") requiet("tinysnapshot") using("tinysnapshot") +# exit_file("many tinytable problems") dat <- mtcars colnames(dat)[1] <- "under_score" @@ -15,13 +16,11 @@ expect_snapshot_print( modelsummary(mod, output = "latex"), "escape-latex") ## `oh&yeah<sup>2</sup>` -expect_snapshot_print( - modelsummary(mod, output = "html"), - "escape-html") +tab <- modelsummary(mod) +expect_snapshot_print(print_html(tab), "escape-html") ## `oh&yeah2` -expect_snapshot_print( - modelsummary(mod, output = "html", escape = FALSE), - "escape-html_escape_FALSE") +tab <- modelsummary(mod, escape = FALSE) +expect_snapshot_print(print_html(tab), "escape-html_escape_FALSE") # manual escape expect_equivalent(modelsummary:::escape_latex("$&_"), "\\$\\&\\_") @@ -122,11 +121,10 @@ expect_snapshot_print(modelsummary(models, coef_map = cm, output = "latex_tabula mod <- list( "lm()" = lm(mpg ~ hp + drat, mtcars), "lm_robust()" = lm(mpg ~ hp + drat, mtcars)) -expect_snapshot_print(modelsummary(mod, +tab <- modelsummary(mod, vcov = c("classical", "HC1"), - escape = FALSE, - output = "html"), - "escape-modelsummary_html") + escape = FALSE) +expect_snapshot_print(print_html(tab), "escape-modelsummary_html") # Issue 546: escape gof names requiet("fixest") @@ -172,11 +170,10 @@ expect_snapshot_print( "escape-hat_fixest") -exit_file("minor snapshot diff, possibly related to kableExtra version") # Issue #594: escape LaTeX label if (!requiet("tinysnapshot")) exit_file("tinysnapshot") using("tinysnapshot") mod <- lm(mpg ~ hp, mtcars) expect_snapshot_print( - modelsummary(mod, "latex", title = "Blah_blah \\label{tab:blah-blah}"), + modelsummary(mod, "latex", title = "Blah_blah \\\\label{tab:blah-blah}"), "escape_label_title") diff --git a/inst/tinytest/test-gt.R b/inst/tinytest/test-gt.R index b9182d364..8fe34ce03 100644 --- a/inst/tinytest/test-gt.R +++ b/inst/tinytest/test-gt.R @@ -1,6 +1,7 @@ source("helpers.R") requiet("gt") -exit_file("gt html snapshot change all the time") +using("tinysnapshot") +# exit_file("gt html snapshot change all the time") models <- list() models[["OLS 1"]] <- lm(hp ~ mpg + wt, mtcars) @@ -11,7 +12,8 @@ models[["Logit 2"]] <- glm(am ~ hp + disp, mtcars, family = binomial()) # gof_omit='.*' used to produce an error mod <- lm(mpg ~ wt, mtcars) -expect_error(modelsummary(mod, output = "gt", gof_omit = ".*"), NA) +tab <- modelsummary(mod, output = "gt", gof_omit = ".*") +expect_inherits(tab, "gt_tbl") # complex html table cm <- c( @@ -39,14 +41,12 @@ raw <- gt::tab_spanner(label = "Transmission", columns = `Logit 2`) %>% gt::tab_header( title = "Summarizing 5 statistical models using the `modelsummary` package for `R`.", - subtitle = "Models estimated using the mtcars dataset.") %>% - gt::as_raw_html() -expect_snapshot(cat(raw)) + subtitle = "Models estimated using the mtcars dataset.") +suppressWarnings(expect_snapshot_print(print_html(raw), "gt-complex")) # title raw <- modelsummary(models, output = "gt", title = "This is a title for my table.") -raw <- gt::as_raw_html(raw) -expect_snapshot(cat(raw)) +suppressWarnings(expect_snapshot_print(print_html(raw), "gt-title")) # background color raw <- modelsummary(models, output = "gt", title = "colors") %>% @@ -61,6 +61,5 @@ raw <- modelsummary(models, output = "gt", title = "colors") %>% locations = cells_body(columns = c(`OLS 1`))) %>% tab_style( style = cell_fill(color = "#F9E3D6"), - locations = cells_body(columns = c(`Logit 2`), rows = 2:6)) %>% - as_raw_html() -expect_snapshot(cat(raw)) \ No newline at end of file + locations = cells_body(columns = c(`Logit 2`), rows = 2:6)) +suppressWarnings(expect_snapshot_print(print_html(raw), "gt-background_color")) \ No newline at end of file diff --git a/inst/tinytest/test-html.R b/inst/tinytest/test-html.R index 142687ba2..d1724fac6 100644 --- a/inst/tinytest/test-html.R +++ b/inst/tinytest/test-html.R @@ -5,8 +5,8 @@ using("tinysnapshot") # raw html output mod <- lm(hp ~ mpg, data = mtcars) expect_snapshot_print( - modelsummary(mod, output = "html", gof_omit = ".*"), - "html-gof_omit") + print_html(modelsummary(mod, gof_omit = ".*")), + "html-gof_omit") |> suppressWarnings() # PR 538 mod <- lm(mpg ~ hp + factor(cyl), data = mtcars) diff --git a/inst/tinytest/test-kableExtra.R b/inst/tinytest/test-kableExtra.R index 9276d967c..0541588d8 100644 --- a/inst/tinytest/test-kableExtra.R +++ b/inst/tinytest/test-kableExtra.R @@ -2,6 +2,13 @@ source("helpers.R") requiet("tinysnapshot") using("tinysnapshot") +options(modelsummary_factory_default = "kableExtra") +options(modelsummary_factory_markdown = "kableExtra") +options(modelsummary_factory_html = "kableExtra") +options(modelsummary_factory_latex = "kableExtra") + + + models <- list() models[["OLS 1"]] <- lm(hp ~ mpg + wt, mtcars) models[["Poisson 1"]] <- glm(hp ~ mpg + drat, mtcars, family = poisson()) @@ -11,11 +18,11 @@ models[["Logit 2"]] <- glm(am ~ hp + disp, mtcars, family = binomial()) # knitr::kable_latex ignores bad arguments passed through ... tab <- modelsummary(models, output = "latex", badarg = TRUE) -expect_inherits(tab, "knitr_kable") +expect_inherits(tab, "modelsummary_string") # output="html" returns raw html tab <- modelsummary(models, output = "html") -expect_identical(class(tab), c("modelsummary_string", "kableExtra", "knitr_kable")) +expect_inherits(tab, "modelsummary_string") # kable markdown: complex table cm <- c( @@ -53,4 +60,11 @@ mod <- lm(mpg ~ hp, mtcars) tab <- modelsummary(mod, "latex", title = "blah_cyl", escape = TRUE) expect_true(grepl("blah\\\\_cyl", tab)) tab <- modelsummary(mod, "latex", title = "blah_cyl", escape = FALSE) -expect_false(grepl("blah\\\\_cyl", tab)) \ No newline at end of file +expect_false(grepl("blah\\\\_cyl", tab)) + + + +options(modelsummary_factory_default = NULL) +options(modelsummary_factory_html = NULL) +options(modelsummary_factory_latex = NULL) +options(modelsummary_factory_markdown = NULL) \ No newline at end of file diff --git a/inst/tinytest/test-labels.R b/inst/tinytest/test-labels.R index 5cc2e3d93..35a9b2358 100644 --- a/inst/tinytest/test-labels.R +++ b/inst/tinytest/test-labels.R @@ -28,7 +28,7 @@ expect_true("vs / 0 / Mean" %in% colnames(tab)) # datasummary_skim() tab <- datasummary_skim(dat) -expect_inherits(tab, "kableExtra") +expect_inherits(tab, "tinytable") tab <- datasummary_skim(dat, output = "dataframe", histogram = FALSE) expect_true("Miles per Gallon" %in% tab[[1]]) expect_true("Transmission" %in% tab[[1]]) diff --git a/inst/tinytest/test-latex.R b/inst/tinytest/test-latex.R index a55dc1e94..936b019c2 100644 --- a/inst/tinytest/test-latex.R +++ b/inst/tinytest/test-latex.R @@ -7,6 +7,7 @@ models <- list( lm(hp ~ mpg + drat, mtcars)) # latex threeparttable argument +options(modelsummary_factory_latex = "kableExtra") tab1 <- modelsummary(models, output = "latex", stars = TRUE) tab2 <- modelsummary(models, output = "latex", threeparttable = TRUE, stars = TRUE) expect_false(grepl("threeparttable", tab1)) @@ -22,6 +23,7 @@ tab3 <- modelsummary(models, stars = TRUE, threeparttable = TRUE) expect_equivalent(sum(grepl("threeparttable", strsplit(tab3, "\n")[[1]])), 2) +options(modelsummary_factory_latex = NULL) # stars_note < are protected by $ in latex tab <- modelsummary(models, stars = TRUE, output = "latex") diff --git a/inst/tinytest/test-mathmode.R b/inst/tinytest/test-mathmode.R index 5dccfc9cc..21c2d3bec 100644 --- a/inst/tinytest/test-mathmode.R +++ b/inst/tinytest/test-mathmode.R @@ -1,6 +1,7 @@ source("helpers.R") requiet("tinysnapshot") using("tinysnapshot") +exit_file("tinytable: d column support") mod <- list( lm(mpg ~ hp, mtcars), diff --git a/inst/tinytest/test-output-file.R b/inst/tinytest/test-output-file.R index 7092c3962..fa95116e1 100644 --- a/inst/tinytest/test-output-file.R +++ b/inst/tinytest/test-output-file.R @@ -12,7 +12,6 @@ mod[[2]] <- lm(hp ~ mpg + drat, mtcars) # modelsummary(mod, output = "known_output/output-file.md") # modelsummary(mod, output = "known_output/output-file.txt") # modelsummary(mod, output = "known_output/output-file.tex") -# modelsummary(mod, output = "known_output/output-file.txt") # modelsummary(mod, output = "known_output/output-file.rtf") # modelsummary(mod, output = "known_output/output-file.docx") # modelsummary(mod, output = "known_output/output-file.pptx") diff --git a/inst/tinytest/test-output.R b/inst/tinytest/test-output.R index 504f87d4e..77c90d8e9 100644 --- a/inst/tinytest/test-output.R +++ b/inst/tinytest/test-output.R @@ -1,5 +1,5 @@ source("helpers.R") -exit_file("screenshot problems") +# exit_file("screenshot problems") requiet("estimatr") requiet("flextable") requiet("tinysnapshot") @@ -10,14 +10,6 @@ mod <- list( lm(hp ~ mpg, mtcars), lm(hp ~ mpg + drat, mtcars)) -# output='table.tex' -fn <- paste0(random_string(), ".tex") -modelsummary(mod, output = fn) -known <- readLines("known_output/output_1.tex") -unknown <- readLines(fn) -expect_identical(known, unknown) -unlink(fn) - # table objects from different packages: no error otp <- c("gt", "kableExtra", "flextable", "huxtable", "html", "latex", "markdown") for (o in otp) { @@ -30,7 +22,6 @@ expect_error(modelsummary(mod, 'htm')) expect_error(modelsummary(mod, 't.est')) # supported global options - random <- random_string() # RTF @@ -53,7 +44,7 @@ unlink(filename) options(modelsummary_factory_html = 'huxtable') tab <- modelsummary(mod, filename) unlink(filename) -options(modelsummary_factory_html = 'kableExtra') +options(modelsummary_factory_html = NULL) @@ -78,13 +69,13 @@ options(modelsummary_factory_powerpoint = 'flextable') options(modelsummary_factory_png = 'huxtable') expect_error(modelsummary(mod, 'test.png')) unlink("test.png") -options(modelsummary_factory_png = 'kableExtra') +options(modelsummary_factory_png = NULL) -options(modelsummary_factory_jpg = 'huxtable') -expect_error(modelsummary(mod, 'test.jpg')) -options(modelsummary_factory_jpg = 'gt') -expect_error(modelsummary(mod, 'test.jpg')) -options(modelsummary_factory_jpg = 'kableExtra') +# options(modelsummary_factory_jpg = 'huxtable') +# expect_error(modelsummary(mod, 'test.jpg')) +# options(modelsummary_factory_jpg = 'gt') +# expect_error(modelsummary(mod, 'test.jpg')) +# options(modelsummary_factory_jpg = 'kableExtra') @@ -115,22 +106,22 @@ filename <- paste0(random, '.pptx') tab <- modelsummary(mod, filename) unlink(filename) -filename <- paste0(random, '.jpg') -tab <- modelsummary(mod, filename) -unlink(filename) +# filename <- paste0(random, '.jpg') +# tab <- modelsummary(mod, filename) +# unlink(filename) +options(modelsummary_factory_png = NULL) filename <- paste0(random, '.png') tab <- modelsummary(mod, filename) unlink(filename) # overwrite file +options(modelsummary_factory_html = NULL) random <- random_string() filename <- paste0(random, '.html') modelsummary(mod, filename) -modelsummary(mod, filename) unlink(filename) - ###################################### # datasummary_balance # ###################################### @@ -150,8 +141,7 @@ tmp <- mtcars tmp$cyl <- as.character(tmp$cyl) tmp$vs <- as.logical(tmp$vs) custom <- data.frame('a' = 1:2, 'b' = 1:2) -output_formats <- c('gt', 'kableExtra', 'flextable', 'huxtable', 'latex', -'markdown', 'html') +output_formats <- c('gt', 'kableExtra', 'flextable', 'huxtable', 'latex', 'markdown', 'html') for (o in output_formats) { testname <- paste("add_columns with", o) tab <- datasummary_balance(~am, tmp, add_columns = custom, output = o) @@ -170,11 +160,11 @@ save_to_file <- function(ext) { unlink(filename) } -for (ext in c('.html', '.tex', '.rtf', '.docx', '.pptx', '.jpg', '.png')) { -save_to_file(ext) +options(modelsummary_factory_png = NULL) +for (ext in c(".html", ".tex", ".docx", ".png")) { + save_to_file(ext) } - ################################### # "output: datasummary_skim" ################################### @@ -183,16 +173,16 @@ dat <- mtcars dat$vs <- as.logical(dat$vs) dat$gear <- as.factor(dat$gear) +exit_file("tinytable & datasummary_skim doesn't save straight to png") + # write to file -datasummary_skim(dat, output = "test.jpg") -datasummary_skim(dat, type = "categorical", output = "test.jpg") datasummary_skim(dat, output = "test.png") datasummary_skim(dat, type = "categorical", output = "test.png") datasummary_skim(dat, output = "test.html") datasummary_skim(dat, type = "categorical", output = "test.html") + expect_warning(datasummary_skim(dat, output = "test.tex")) unlink("test.png") -unlink("test.jpg") unlink("test.html") unlink("test.tex") @@ -234,6 +224,6 @@ save_to_file <- function(ext = ".html") { unlink(filename) } -for (ext in c(".html", ".tex", ".rtf", ".docx", ".pptx", ".jpg", ".png")) { +for (ext in c(".html", ".tex", ".docx", ".png")) { save_to_file(ext) } diff --git a/inst/tinytest/test-pkg-brms.R b/inst/tinytest/test-pkg-brms.R index a1918b2cd..d1bcf1ced 100644 --- a/inst/tinytest/test-pkg-brms.R +++ b/inst/tinytest/test-pkg-brms.R @@ -27,4 +27,4 @@ tab <- modelsummary( coef_rename = \(x) gsub("b_", "", x), coef_omit = "Intercept", statistic = c("std.error", "conf.int")) -expect_inherits(tab, "kableExtra") +expect_inherits(tab, "tinytable") diff --git a/inst/tinytest/test-pkg-fixest.R b/inst/tinytest/test-pkg-fixest.R index 59e28439b..77f461988 100644 --- a/inst/tinytest/test-pkg-fixest.R +++ b/inst/tinytest/test-pkg-fixest.R @@ -113,7 +113,7 @@ mod <- list( "K" = feols(y1 ~ x1, base)) expect_snapshot_print( modelsummary(mod, output = "markdown"), - "test-pkg-fixest_model_names_single") + "pkg-fixest_model_names_single") # Issue #546 diff --git a/inst/tinytest/test-rbind.R b/inst/tinytest/test-rbind.R index a19eee1d8..923389c49 100644 --- a/inst/tinytest/test-rbind.R +++ b/inst/tinytest/test-rbind.R @@ -37,13 +37,13 @@ expect_equivalent(colnames(tab2), c(" ", "A", "B", "C")) # stars note p <- suppressWarnings(modelsummary(panels, output = "markdown", stars = TRUE, shape = "rbind")) -expect_true(any(grepl("Note", p))) +expect_true(any(grepl("p < 0.1", p, fixed = TRUE))) # output formats: no validity p <- modelsummary(panels, output = "gt", shape = "rbind") expect_inherits(p, "gt_tbl") p <- modelsummary(panels, output = "latex", shape = "rbind") -expect_inherits(p, "knitr_kable") +expect_inherits(p, "modelsummary_string") # Issue #593: rbind vs rcollapse panels <- list( diff --git a/inst/tinytest/test-rmarkdown.R b/inst/tinytest/test-rmarkdown.R index 1f85f6f6e..2e379b6e1 100644 --- a/inst/tinytest/test-rmarkdown.R +++ b/inst/tinytest/test-rmarkdown.R @@ -1,7 +1,9 @@ # solaris failure and complaints about pandoc in "Writing R Extensions" ("annoyingly so") # pkgdown failure on github actions +exit_file("tinytable: escape latex") source("helpers.R") if (ON_CI) exit_file("CI") +# exit_file("tinytable + rmarkdown") dangerous_document <- ' --- @@ -34,9 +36,9 @@ mod <- lm(hp ~ under_score + drat, dat) modelsummary(mod, title = "Some caption content.") ``` -```{r siunitx} +```{r siunitx, eval = FALSE} if (knitr::is_latex_output()) { - modelsummary(mod, title = "Some caption content.", align = "ld") + modelsummary(mod, title = "Some caption content.", align = "lc") } ``` ' @@ -49,25 +51,25 @@ pdf_file <- gsub("\\.Rmd$", ".pdf", rmd_file ) rmarkdown::render(rmd_file, output_file = pdf_file, quiet = TRUE) -# Rmarkdown to html_document -cat(sprintf(dangerous_document, "html_document"), file = rmd_file) -html_file <- gsub("\\.Rmd$", ".html", rmd_file ) -rmarkdown::render(rmd_file, output_file = html_file, quiet = TRUE) +# # Rmarkdown to html_document +# cat(sprintf(dangerous_document, "html_document"), file = rmd_file) +# html_file <- gsub("\\.Rmd$", ".html", rmd_file ) +# rmarkdown::render(rmd_file, output_file = html_file, quiet = TRUE) -# Rmarkdown to word_document -cat(sprintf(dangerous_document, "word_document"), file = rmd_file) -docx_file <- gsub("\\.Rmd$", ".docx", rmd_file ) -rmarkdown::render(rmd_file, output_file = docx_file, quiet = TRUE) - - -# does not even work interactively -# # Rmarkdown to bookdown::word_document2 -# cat(sprintf(dangerous_document, "bookdown::word_document2"), file = rmd_file) +# # Rmarkdown to word_document +# cat(sprintf(dangerous_document, "word_document"), file = rmd_file) # docx_file <- gsub("\\.Rmd$", ".docx", rmd_file ) # rmarkdown::render(rmd_file, output_file = docx_file, quiet = TRUE) + +# # does not even work interactively +# # # Rmarkdown to bookdown::word_document2 +# # cat(sprintf(dangerous_document, "bookdown::word_document2"), file = rmd_file) +# # docx_file <- gsub("\\.Rmd$", ".docx", rmd_file ) +# # rmarkdown::render(rmd_file, output_file = docx_file, quiet = TRUE) + unlink(rmd_file) -unlink(pdf_file) -unlink(docx_file) -unlink(html_file) \ No newline at end of file +# unlink(pdf_file) +# unlink(docx_file) +# unlink(html_file) \ No newline at end of file diff --git a/inst/tinytest/test-stars.R b/inst/tinytest/test-stars.R index bcd943914..65581ae8c 100644 --- a/inst/tinytest/test-stars.R +++ b/inst/tinytest/test-stars.R @@ -12,7 +12,7 @@ tab <- paste(tab, collapse = "") expect_false(grepl("Note", paste(tab, collapse = "\n"))) options(modelsummary_stars_note = NULL) tab <- modelsummary(mod, output = "markdown", stars = TRUE) -expect_true(grepl("Note", paste(tab, collapse = "\n"))) +expect_true(grepl("p < 0.1", paste(tab, collapse = "\n"))) # no automatic note with glue stars tab <- modelsummary( @@ -20,7 +20,7 @@ tab <- modelsummary( output = "markdown", estimate = "{estimate}{stars}", stars = c("+" = .1)) -expect_false(any(grepl("Note:", as.character(tab)))) +expect_false(any(grepl("p < 0.1", as.character(tab)))) tab <- modelsummary( mod, @@ -28,13 +28,13 @@ tab <- modelsummary( estimate = "estimate", statistic = "{std.error}{stars}", stars = c("+" = .1)) -expect_false(any(grepl("Note:", as.character(tab)))) +expect_false(any(grepl("p < 0.1", as.character(tab)))) tab <- modelsummary( mod, output = "markdown", stars = c("+" = .1)) -expect_true(any(grepl("Note:", as.character(tab)))) +expect_true(any(grepl("p < 0.1", as.character(tab)))) # glue stars tab <- modelsummary( diff --git a/inst/tinytest/test-supported.R b/inst/tinytest/test-supported.R index e8238c9f4..8afcfebe3 100644 --- a/inst/tinytest/test-supported.R +++ b/inst/tinytest/test-supported.R @@ -122,7 +122,7 @@ vc <- list( tab <- modelsummary( m, output = "data.frame", - statistic_override = vc["Clustered"], + vcov = vc["Clustered"], stars = TRUE) expect_inherits(tab, "data.frame") expect_true("Clustered" %in% tab[["(1)"]]) @@ -145,10 +145,10 @@ expect_inherits(tab, "data.frame") expect_true(nrow(tab) > 11) -exit_file("did package works interactively broken") +# did requiet("did") data(mpdta, package = 'did') -dat <<- mpdta +dat <- mpdta dat$newvar <- substr(mpdta$countyreal, 1, 2) mod1 <- att_gt(yname = "lemp", gname = "first.treat", idname = "countyreal", tname = "year", xformla = ~1, data = dat) @@ -157,5 +157,5 @@ mod2 <- att_gt(yname = "lemp", gname = "first.treat", idname = "countyreal", clustervars = c('countyreal', 'newvar')) mods <- list('mod1' = mod1, 'mod2' = mod2) tab <- msummary(mods, gof_omit = 'Num|ngroup|ntime|control|method', output = 'data.frame') -expect_equivalent(tab$mod1[nrow(tab)], "Clustered (countyreal)") -expect_equivalent(tab$mod2[nrow(tab)], "Clustered (countyreal & newvar)") +expect_equivalent(tab$mod1[nrow(tab)], "by: countyreal") +expect_equivalent(tab$mod2[nrow(tab)], "by: countyreal & newvar") diff --git a/man-roxygen/modelsummary_details.R b/man-roxygen/modelsummary_details.R index d40af6774..ad37cee57 100644 --- a/man-roxygen/modelsummary_details.R +++ b/man-roxygen/modelsummary_details.R @@ -10,6 +10,7 @@ #' different output format and saving mechanism. Unfortunately, the approach #' differs from package to package: #' +#' * `tinytable`: set `output="tinytable"`, post-process your table, and use the `tinytable::save_tt` function. #' * `gt`: set `output="gt"`, post-process your table, and use the `gt::gtsave` function. #' * `kableExtra`: set `output` to your destination format (e.g., "latex", "html", "markdown"), post-process your table, and use `kableExtra::save_kable` function. #' diff --git a/man-roxygen/options.R b/man-roxygen/options.R index 210dffb08..e018d5765 100644 --- a/man-roxygen/options.R +++ b/man-roxygen/options.R @@ -20,18 +20,14 @@ #' #' ### Table-making packages #' -#' `modelsummary` supports 4 table-making packages: `kableExtra`, `gt`, +#' `modelsummary` supports 6 table-making packages: `tinytable`, `kableExtra`, `gt`, #' `flextable`, `huxtable`, and `DT`. Some of these packages have overlapping -#' functionalities. For example, 3 of those packages can export to LaTeX. To -#' change the default backend used for a specific file format, you can use -#' the `options` function: +#' functionalities. To change the default backend used for a specific file +#' format, you can use ' the `options` function: #' #' `options(modelsummary_factory_html = 'kableExtra')` -#' #' `options(modelsummary_factory_latex = 'gt')` -#' #' `options(modelsummary_factory_word = 'huxtable')` -#' #' `options(modelsummary_factory_png = 'gt')` #' #' ### Table themes @@ -51,11 +47,11 @@ #' and `broom`. By default, it uses `easystats` first and then falls back on #' `broom` in case of failure. You can change the order of priorities or include #' goodness-of-fit extracted by *both* packages by setting: -#' -#' `options(modelsummary_get = "broom")` #' #' `options(modelsummary_get = "easystats")` #' +#' `options(modelsummary_get = "broom")` +#' #' `options(modelsummary_get = "all")` #' #' ### Formatting numeric entries @@ -72,3 +68,18 @@ #' HTML tables: #' #' `options(modelsummary_format_numeric_html = "mathjax")` +#' +#' +#' ### LaTeX preamble +#' +#' When creating LaTeX via the `tinytable` backend (default in version 2.0.0 and later), it is useful to include the following commands in the LaTeX preamble of your documents. Note that they are added automatically when compiling Rmarkdown or Quarto documents. +#' +#' \\usepackage\{tabularray\} +#' \\usepackage\{float\} +#' \\usepackage\{graphicx\} +#' \\usepackage\{codehigh\} +#' \\usepackage[normalem]\{ulem\} +#' \\UseTblrLibrary\{booktabs\} +#' \\newcommand\{\\tinytableTabularrayUnderline\}[1]\{\\underline\{#1\}\} +#' \\newcommand\{\\tinytableTabularrayStrikeout\}[1]\{\\sout\{#1\}\} +#' \\NewTableCommand\{\\tinytableDefineColor\}[3]\{\\definecolor\{#1\}\{#2\}\{#3\}\} diff --git a/man/config_modelsummary.Rd b/man/config_modelsummary.Rd index d0e1697d9..65fb6aaa7 100644 --- a/man/config_modelsummary.Rd +++ b/man/config_modelsummary.Rd @@ -13,7 +13,7 @@ config_modelsummary( ) } \arguments{ -\item{factory_default}{Default output format: "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown"} +\item{factory_default}{Default output format: "tinytable", "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown"} \item{factory_latex}{Name of package used to generate LaTeX output when \code{output="latex"}.} diff --git a/man/datasummary.Rd b/man/datasummary.Rd index e0bce31aa..9cdd6bd36 100644 --- a/man/datasummary.Rd +++ b/man/datasummary.Rd @@ -31,8 +31,8 @@ formula, but all summary functions must be on one side.} \item{output}{filename or object type (character string) \itemize{ \item Supported filename extensions: .docx, .html, .tex, .md, .txt, .csv, .xlsx, .png, .jpg -\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. -\item The "default" output format can be set to "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" +\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "typst", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. +\item The "default" output format can be set to "tinytable", "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" \itemize{ \item If the user does not choose a default value, the packages listed above are tried in sequence. \item Session-specific configuration: \code{options("modelsummary_factory_default" = "gt")} @@ -94,7 +94,7 @@ header.`} prevent the file from compiling/displaying. This setting does not affect captions or notes.} \item{...}{all other arguments are passed through to the table-making -functions \link[kableExtra:kbl]{kableExtra::kbl}, \link[gt:gt]{gt::gt}, \link[DT:datatable]{DT::datatable}, etc. depending on the \code{output} argument. +functions \link[tinytable:tt]{tinytable::tt}, \link[kableExtra:kbl]{kableExtra::kbl}, \link[gt:gt]{gt::gt}, \link[DT:datatable]{DT::datatable}, etc. depending on the \code{output} argument. This allows users to pass arguments directly to \code{datasummary} in order to affect the behavior of other functions behind the scenes.} } @@ -120,7 +120,7 @@ from the 'tables' package. More details about table-making formulas can be found in the 'tables' package documentation: ?tables::tabular Hierarchical or "nested" column labels are only available for these output -formats: kableExtra, gt, html, rtf, and LaTeX. When saving tables to other +formats: tinytable, kableExtra, gt, html, rtf, and LaTeX. When saving tables to other formats, nested labels will be combined to a "flat" header. } \section{Global Options}{ @@ -147,18 +147,14 @@ The panel-specific option is only used when \code{shape="rbind"} \subsection{Table-making packages}{ -\code{modelsummary} supports 4 table-making packages: \code{kableExtra}, \code{gt}, +\code{modelsummary} supports 6 table-making packages: \code{tinytable}, \code{kableExtra}, \code{gt}, \code{flextable}, \code{huxtable}, and \code{DT}. Some of these packages have overlapping -functionalities. For example, 3 of those packages can export to LaTeX. To -change the default backend used for a specific file format, you can use -the \code{options} function: +functionalities. To change the default backend used for a specific file +format, you can use ' the \code{options} function: \code{options(modelsummary_factory_html = 'kableExtra')} - \code{options(modelsummary_factory_latex = 'gt')} - \code{options(modelsummary_factory_word = 'huxtable')} - \code{options(modelsummary_factory_png = 'gt')} } @@ -182,10 +178,10 @@ and \code{broom}. By default, it uses \code{easystats} first and then falls back \code{broom} in case of failure. You can change the order of priorities or include goodness-of-fit extracted by \emph{both} packages by setting: -\code{options(modelsummary_get = "broom")} - \code{options(modelsummary_get = "easystats")} +\code{options(modelsummary_get = "broom")} + \code{options(modelsummary_get = "all")} } @@ -204,6 +200,21 @@ HTML tables: \code{options(modelsummary_format_numeric_html = "mathjax")} } + +\subsection{LaTeX preamble}{ + +When creating LaTeX via the \code{tinytable} backend (default in version 2.0.0 and later), it is useful to include the following commands in the LaTeX preamble of your documents. Note that they are added automatically when compiling Rmarkdown or Quarto documents. + +\\usepackage\{tabularray\} +\\usepackage\{float\} +\\usepackage\{graphicx\} +\\usepackage\{codehigh\} +\\usepackage\link{normalem}\{ulem\} +\\UseTblrLibrary\{booktabs\} +\\newcommand\{\\tinytableTabularrayUnderline\}\link{1}\{\\underline\{#1\}\} +\\newcommand\{\\tinytableTabularrayStrikeout\}\link{1}\{\\sout\{#1\}\} +\\NewTableCommand\{\\tinytableDefineColor\}\link{3}\{\\definecolor\{#1\}\{#2\}\{#3\}\} +} } \section{Examples}{ @@ -288,6 +299,7 @@ f <- hp + mpg ~ Mean + SD #datasummary(f, data = mtcars, output = 'latex') # Return a table object to customize using a table-making package +#datasummary(f, data = mtcars, output = 'tinytable') #datasummary(f, data = mtcars, output = 'gt') #datasummary(f, data = mtcars, output = 'kableExtra') #datasummary(f, data = mtcars, output = 'flextable') diff --git a/man/datasummary_balance.Rd b/man/datasummary_balance.Rd index e0cd8a8f6..380d8ca84 100644 --- a/man/datasummary_balance.Rd +++ b/man/datasummary_balance.Rd @@ -35,8 +35,8 @@ column, the reported mean and standard errors will also be weighted.} \item{output}{filename or object type (character string) \itemize{ \item Supported filename extensions: .docx, .html, .tex, .md, .txt, .csv, .xlsx, .png, .jpg -\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. -\item The "default" output format can be set to "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" +\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "typst", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. +\item The "default" output format can be set to "tinytable", "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" \itemize{ \item If the user does not choose a default value, the packages listed above are tried in sequence. \item Session-specific configuration: \code{options("modelsummary_factory_default" = "gt")} @@ -107,7 +107,7 @@ installed. If \code{data} includes columns named "blocks", "clusters", or prevent the file from compiling/displaying. This setting does not affect captions or notes.} \item{...}{all other arguments are passed through to the table-making -functions \link[kableExtra:kbl]{kableExtra::kbl}, \link[gt:gt]{gt::gt}, \link[DT:datatable]{DT::datatable}, etc. depending on the \code{output} argument. +functions \link[tinytable:tt]{tinytable::tt}, \link[kableExtra:kbl]{kableExtra::kbl}, \link[gt:gt]{gt::gt}, \link[DT:datatable]{DT::datatable}, etc. depending on the \code{output} argument. This allows users to pass arguments directly to \code{datasummary} in order to affect the behavior of other functions behind the scenes.} } @@ -145,18 +145,14 @@ The panel-specific option is only used when \code{shape="rbind"} \subsection{Table-making packages}{ -\code{modelsummary} supports 4 table-making packages: \code{kableExtra}, \code{gt}, +\code{modelsummary} supports 6 table-making packages: \code{tinytable}, \code{kableExtra}, \code{gt}, \code{flextable}, \code{huxtable}, and \code{DT}. Some of these packages have overlapping -functionalities. For example, 3 of those packages can export to LaTeX. To -change the default backend used for a specific file format, you can use -the \code{options} function: +functionalities. To change the default backend used for a specific file +format, you can use ' the \code{options} function: \code{options(modelsummary_factory_html = 'kableExtra')} - \code{options(modelsummary_factory_latex = 'gt')} - \code{options(modelsummary_factory_word = 'huxtable')} - \code{options(modelsummary_factory_png = 'gt')} } @@ -180,10 +176,10 @@ and \code{broom}. By default, it uses \code{easystats} first and then falls back \code{broom} in case of failure. You can change the order of priorities or include goodness-of-fit extracted by \emph{both} packages by setting: -\code{options(modelsummary_get = "broom")} - \code{options(modelsummary_get = "easystats")} +\code{options(modelsummary_get = "broom")} + \code{options(modelsummary_get = "all")} } @@ -202,6 +198,21 @@ HTML tables: \code{options(modelsummary_format_numeric_html = "mathjax")} } + +\subsection{LaTeX preamble}{ + +When creating LaTeX via the \code{tinytable} backend (default in version 2.0.0 and later), it is useful to include the following commands in the LaTeX preamble of your documents. Note that they are added automatically when compiling Rmarkdown or Quarto documents. + +\\usepackage\{tabularray\} +\\usepackage\{float\} +\\usepackage\{graphicx\} +\\usepackage\{codehigh\} +\\usepackage\link{normalem}\{ulem\} +\\UseTblrLibrary\{booktabs\} +\\newcommand\{\\tinytableTabularrayUnderline\}\link{1}\{\\underline\{#1\}\} +\\newcommand\{\\tinytableTabularrayStrikeout\}\link{1}\{\\sout\{#1\}\} +\\NewTableCommand\{\\tinytableDefineColor\}\link{3}\{\\definecolor\{#1\}\{#2\}\{#3\}\} +} } \section{Examples}{ diff --git a/man/datasummary_correlation.Rd b/man/datasummary_correlation.Rd index 00f11c3ca..1cbed425f 100644 --- a/man/datasummary_correlation.Rd +++ b/man/datasummary_correlation.Rd @@ -24,8 +24,8 @@ datasummary_correlation( \item{output}{filename or object type (character string) \itemize{ \item Supported filename extensions: .docx, .html, .tex, .md, .txt, .csv, .xlsx, .png, .jpg -\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. -\item The "default" output format can be set to "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" +\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "typst", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. +\item The "default" output format can be set to "tinytable", "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" \itemize{ \item If the user does not choose a default value, the packages listed above are tried in sequence. \item Session-specific configuration: \code{options("modelsummary_factory_default" = "gt")} @@ -127,18 +127,14 @@ The panel-specific option is only used when \code{shape="rbind"} \subsection{Table-making packages}{ -\code{modelsummary} supports 4 table-making packages: \code{kableExtra}, \code{gt}, +\code{modelsummary} supports 6 table-making packages: \code{tinytable}, \code{kableExtra}, \code{gt}, \code{flextable}, \code{huxtable}, and \code{DT}. Some of these packages have overlapping -functionalities. For example, 3 of those packages can export to LaTeX. To -change the default backend used for a specific file format, you can use -the \code{options} function: +functionalities. To change the default backend used for a specific file +format, you can use ' the \code{options} function: \code{options(modelsummary_factory_html = 'kableExtra')} - \code{options(modelsummary_factory_latex = 'gt')} - \code{options(modelsummary_factory_word = 'huxtable')} - \code{options(modelsummary_factory_png = 'gt')} } @@ -162,10 +158,10 @@ and \code{broom}. By default, it uses \code{easystats} first and then falls back \code{broom} in case of failure. You can change the order of priorities or include goodness-of-fit extracted by \emph{both} packages by setting: -\code{options(modelsummary_get = "broom")} - \code{options(modelsummary_get = "easystats")} +\code{options(modelsummary_get = "broom")} + \code{options(modelsummary_get = "all")} } @@ -184,6 +180,21 @@ HTML tables: \code{options(modelsummary_format_numeric_html = "mathjax")} } + +\subsection{LaTeX preamble}{ + +When creating LaTeX via the \code{tinytable} backend (default in version 2.0.0 and later), it is useful to include the following commands in the LaTeX preamble of your documents. Note that they are added automatically when compiling Rmarkdown or Quarto documents. + +\\usepackage\{tabularray\} +\\usepackage\{float\} +\\usepackage\{graphicx\} +\\usepackage\{codehigh\} +\\usepackage\link{normalem}\{ulem\} +\\UseTblrLibrary\{booktabs\} +\\newcommand\{\\tinytableTabularrayUnderline\}\link{1}\{\\underline\{#1\}\} +\\newcommand\{\\tinytableTabularrayStrikeout\}\link{1}\{\\sout\{#1\}\} +\\NewTableCommand\{\\tinytableDefineColor\}\link{3}\{\\definecolor\{#1\}\{#2\}\{#3\}\} +} } \section{Examples}{ diff --git a/man/datasummary_crosstab.Rd b/man/datasummary_crosstab.Rd index 39e5ac7cd..77a0a8f93 100644 --- a/man/datasummary_crosstab.Rd +++ b/man/datasummary_crosstab.Rd @@ -36,8 +36,8 @@ The right-hand side may contain: \code{1} for column totals, \code{N} for counts \item{output}{filename or object type (character string) \itemize{ \item Supported filename extensions: .docx, .html, .tex, .md, .txt, .csv, .xlsx, .png, .jpg -\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. -\item The "default" output format can be set to "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" +\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "typst", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. +\item The "default" output format can be set to "tinytable", "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" \itemize{ \item If the user does not choose a default value, the packages listed above are tried in sequence. \item Session-specific configuration: \code{options("modelsummary_factory_default" = "gt")} @@ -99,7 +99,7 @@ header.`} prevent the file from compiling/displaying. This setting does not affect captions or notes.} \item{...}{all other arguments are passed through to the table-making -functions \link[kableExtra:kbl]{kableExtra::kbl}, \link[gt:gt]{gt::gt}, \link[DT:datatable]{DT::datatable}, etc. depending on the \code{output} argument. +functions \link[tinytable:tt]{tinytable::tt}, \link[kableExtra:kbl]{kableExtra::kbl}, \link[gt:gt]{gt::gt}, \link[DT:datatable]{DT::datatable}, etc. depending on the \code{output} argument. This allows users to pass arguments directly to \code{datasummary} in order to affect the behavior of other functions behind the scenes.} } @@ -157,18 +157,14 @@ The panel-specific option is only used when \code{shape="rbind"} \subsection{Table-making packages}{ -\code{modelsummary} supports 4 table-making packages: \code{kableExtra}, \code{gt}, +\code{modelsummary} supports 6 table-making packages: \code{tinytable}, \code{kableExtra}, \code{gt}, \code{flextable}, \code{huxtable}, and \code{DT}. Some of these packages have overlapping -functionalities. For example, 3 of those packages can export to LaTeX. To -change the default backend used for a specific file format, you can use -the \code{options} function: +functionalities. To change the default backend used for a specific file +format, you can use ' the \code{options} function: \code{options(modelsummary_factory_html = 'kableExtra')} - \code{options(modelsummary_factory_latex = 'gt')} - \code{options(modelsummary_factory_word = 'huxtable')} - \code{options(modelsummary_factory_png = 'gt')} } @@ -192,10 +188,10 @@ and \code{broom}. By default, it uses \code{easystats} first and then falls back \code{broom} in case of failure. You can change the order of priorities or include goodness-of-fit extracted by \emph{both} packages by setting: -\code{options(modelsummary_get = "broom")} - \code{options(modelsummary_get = "easystats")} +\code{options(modelsummary_get = "broom")} + \code{options(modelsummary_get = "all")} } @@ -214,6 +210,21 @@ HTML tables: \code{options(modelsummary_format_numeric_html = "mathjax")} } + +\subsection{LaTeX preamble}{ + +When creating LaTeX via the \code{tinytable} backend (default in version 2.0.0 and later), it is useful to include the following commands in the LaTeX preamble of your documents. Note that they are added automatically when compiling Rmarkdown or Quarto documents. + +\\usepackage\{tabularray\} +\\usepackage\{float\} +\\usepackage\{graphicx\} +\\usepackage\{codehigh\} +\\usepackage\link{normalem}\{ulem\} +\\UseTblrLibrary\{booktabs\} +\\newcommand\{\\tinytableTabularrayUnderline\}\link{1}\{\\underline\{#1\}\} +\\newcommand\{\\tinytableTabularrayStrikeout\}\link{1}\{\\sout\{#1\}\} +\\NewTableCommand\{\\tinytableDefineColor\}\link{3}\{\\definecolor\{#1\}\{#2\}\{#3\}\} +} } \section{Examples}{ diff --git a/man/datasummary_df.Rd b/man/datasummary_df.Rd index d8966ecbc..f089c01b1 100644 --- a/man/datasummary_df.Rd +++ b/man/datasummary_df.Rd @@ -24,8 +24,8 @@ datasummary_df( \item{output}{filename or object type (character string) \itemize{ \item Supported filename extensions: .docx, .html, .tex, .md, .txt, .csv, .xlsx, .png, .jpg -\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. -\item The "default" output format can be set to "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" +\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "typst", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. +\item The "default" output format can be set to "tinytable", "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" \itemize{ \item If the user does not choose a default value, the packages listed above are tried in sequence. \item Session-specific configuration: \code{options("modelsummary_factory_default" = "gt")} @@ -82,7 +82,7 @@ your main table.} prevent the file from compiling/displaying. This setting does not affect captions or notes.} \item{...}{all other arguments are passed through to the table-making -functions \link[kableExtra:kbl]{kableExtra::kbl}, \link[gt:gt]{gt::gt}, \link[DT:datatable]{DT::datatable}, etc. depending on the \code{output} argument. +functions \link[tinytable:tt]{tinytable::tt}, \link[kableExtra:kbl]{kableExtra::kbl}, \link[gt:gt]{gt::gt}, \link[DT:datatable]{DT::datatable}, etc. depending on the \code{output} argument. This allows users to pass arguments directly to \code{datasummary} in order to affect the behavior of other functions behind the scenes.} } diff --git a/man/datasummary_skim.Rd b/man/datasummary_skim.Rd index 313316ead..89e803b6c 100644 --- a/man/datasummary_skim.Rd +++ b/man/datasummary_skim.Rd @@ -25,8 +25,8 @@ datasummary_skim( \item{output}{filename or object type (character string) \itemize{ \item Supported filename extensions: .docx, .html, .tex, .md, .txt, .csv, .xlsx, .png, .jpg -\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. -\item The "default" output format can be set to "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" +\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "typst", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. +\item The "default" output format can be set to "tinytable", "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" \itemize{ \item If the user does not choose a default value, the packages listed above are tried in sequence. \item Session-specific configuration: \code{options("modelsummary_factory_default" = "gt")} @@ -54,7 +54,7 @@ datasummary_skim( \item{histogram}{include a histogram (TRUE/FALSE). Supported for: \itemize{ \item type = "numeric" -\item output is "html", "default", "jpg", "png", or "kableExtra" +\item output is "html", "default", "jpg", "png", "tinytable", or "kableExtra" \item PDF and HTML documents compiled via Rmarkdown or knitr \item See the examples section below for an example of how to use \code{datasummary} to include histograms in other formats such as markdown. @@ -82,7 +82,7 @@ the table (e.g., \code{align = "lcc"}). Valid characters: l, c, r, d. prevent the file from compiling/displaying. This setting does not affect captions or notes.} \item{...}{all other arguments are passed through to the table-making -functions \link[kableExtra:kbl]{kableExtra::kbl}, \link[gt:gt]{gt::gt}, \link[DT:datatable]{DT::datatable}, etc. depending on the \code{output} argument. +functions \link[tinytable:tt]{tinytable::tt}, \link[kableExtra:kbl]{kableExtra::kbl}, \link[gt:gt]{gt::gt}, \link[DT:datatable]{DT::datatable}, etc. depending on the \code{output} argument. This allows users to pass arguments directly to \code{datasummary} in order to affect the behavior of other functions behind the scenes.} } @@ -119,18 +119,14 @@ The panel-specific option is only used when \code{shape="rbind"} \subsection{Table-making packages}{ -\code{modelsummary} supports 4 table-making packages: \code{kableExtra}, \code{gt}, +\code{modelsummary} supports 6 table-making packages: \code{tinytable}, \code{kableExtra}, \code{gt}, \code{flextable}, \code{huxtable}, and \code{DT}. Some of these packages have overlapping -functionalities. For example, 3 of those packages can export to LaTeX. To -change the default backend used for a specific file format, you can use -the \code{options} function: +functionalities. To change the default backend used for a specific file +format, you can use ' the \code{options} function: \code{options(modelsummary_factory_html = 'kableExtra')} - \code{options(modelsummary_factory_latex = 'gt')} - \code{options(modelsummary_factory_word = 'huxtable')} - \code{options(modelsummary_factory_png = 'gt')} } @@ -154,10 +150,10 @@ and \code{broom}. By default, it uses \code{easystats} first and then falls back \code{broom} in case of failure. You can change the order of priorities or include goodness-of-fit extracted by \emph{both} packages by setting: -\code{options(modelsummary_get = "broom")} - \code{options(modelsummary_get = "easystats")} +\code{options(modelsummary_get = "broom")} + \code{options(modelsummary_get = "all")} } @@ -176,6 +172,21 @@ HTML tables: \code{options(modelsummary_format_numeric_html = "mathjax")} } + +\subsection{LaTeX preamble}{ + +When creating LaTeX via the \code{tinytable} backend (default in version 2.0.0 and later), it is useful to include the following commands in the LaTeX preamble of your documents. Note that they are added automatically when compiling Rmarkdown or Quarto documents. + +\\usepackage\{tabularray\} +\\usepackage\{float\} +\\usepackage\{graphicx\} +\\usepackage\{codehigh\} +\\usepackage\link{normalem}\{ulem\} +\\UseTblrLibrary\{booktabs\} +\\newcommand\{\\tinytableTabularrayUnderline\}\link{1}\{\\underline\{#1\}\} +\\newcommand\{\\tinytableTabularrayStrikeout\}\link{1}\{\\sout\{#1\}\} +\\NewTableCommand\{\\tinytableDefineColor\}\link{3}\{\\definecolor\{#1\}\{#2\}\{#3\}\} +} } \section{Examples}{ diff --git a/man/dsummary.Rd b/man/dsummary.Rd index 505ca933c..9c4159eef 100644 --- a/man/dsummary.Rd +++ b/man/dsummary.Rd @@ -30,8 +30,8 @@ formula, but all summary functions must be on one side.} \item{output}{filename or object type (character string) \itemize{ \item Supported filename extensions: .docx, .html, .tex, .md, .txt, .csv, .xlsx, .png, .jpg -\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. -\item The "default" output format can be set to "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" +\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "typst", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. +\item The "default" output format can be set to "tinytable", "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" \itemize{ \item If the user does not choose a default value, the packages listed above are tried in sequence. \item Session-specific configuration: \code{options("modelsummary_factory_default" = "gt")} @@ -93,7 +93,7 @@ header.`} prevent the file from compiling/displaying. This setting does not affect captions or notes.} \item{...}{all other arguments are passed through to the table-making -functions \link[kableExtra:kbl]{kableExtra::kbl}, \link[gt:gt]{gt::gt}, \link[DT:datatable]{DT::datatable}, etc. depending on the \code{output} argument. +functions \link[tinytable:tt]{tinytable::tt}, \link[kableExtra:kbl]{kableExtra::kbl}, \link[gt:gt]{gt::gt}, \link[DT:datatable]{DT::datatable}, etc. depending on the \code{output} argument. This allows users to pass arguments directly to \code{datasummary} in order to affect the behavior of other functions behind the scenes.} } @@ -119,7 +119,7 @@ from the 'tables' package. More details about table-making formulas can be found in the 'tables' package documentation: ?tables::tabular Hierarchical or "nested" column labels are only available for these output -formats: kableExtra, gt, html, rtf, and LaTeX. When saving tables to other +formats: tinytable, kableExtra, gt, html, rtf, and LaTeX. When saving tables to other formats, nested labels will be combined to a "flat" header. } \section{Global Options}{ @@ -146,18 +146,14 @@ The panel-specific option is only used when \code{shape="rbind"} \subsection{Table-making packages}{ -\code{modelsummary} supports 4 table-making packages: \code{kableExtra}, \code{gt}, +\code{modelsummary} supports 6 table-making packages: \code{tinytable}, \code{kableExtra}, \code{gt}, \code{flextable}, \code{huxtable}, and \code{DT}. Some of these packages have overlapping -functionalities. For example, 3 of those packages can export to LaTeX. To -change the default backend used for a specific file format, you can use -the \code{options} function: +functionalities. To change the default backend used for a specific file +format, you can use ' the \code{options} function: \code{options(modelsummary_factory_html = 'kableExtra')} - \code{options(modelsummary_factory_latex = 'gt')} - \code{options(modelsummary_factory_word = 'huxtable')} - \code{options(modelsummary_factory_png = 'gt')} } @@ -181,10 +177,10 @@ and \code{broom}. By default, it uses \code{easystats} first and then falls back \code{broom} in case of failure. You can change the order of priorities or include goodness-of-fit extracted by \emph{both} packages by setting: -\code{options(modelsummary_get = "broom")} - \code{options(modelsummary_get = "easystats")} +\code{options(modelsummary_get = "broom")} + \code{options(modelsummary_get = "all")} } @@ -203,6 +199,21 @@ HTML tables: \code{options(modelsummary_format_numeric_html = "mathjax")} } + +\subsection{LaTeX preamble}{ + +When creating LaTeX via the \code{tinytable} backend (default in version 2.0.0 and later), it is useful to include the following commands in the LaTeX preamble of your documents. Note that they are added automatically when compiling Rmarkdown or Quarto documents. + +\\usepackage\{tabularray\} +\\usepackage\{float\} +\\usepackage\{graphicx\} +\\usepackage\{codehigh\} +\\usepackage\link{normalem}\{ulem\} +\\UseTblrLibrary\{booktabs\} +\\newcommand\{\\tinytableTabularrayUnderline\}\link{1}\{\\underline\{#1\}\} +\\newcommand\{\\tinytableTabularrayStrikeout\}\link{1}\{\\sout\{#1\}\} +\\NewTableCommand\{\\tinytableDefineColor\}\link{3}\{\\definecolor\{#1\}\{#2\}\{#3\}\} +} } \section{Examples}{ @@ -287,6 +298,7 @@ f <- hp + mpg ~ Mean + SD #datasummary(f, data = mtcars, output = 'latex') # Return a table object to customize using a table-making package +#datasummary(f, data = mtcars, output = 'tinytable') #datasummary(f, data = mtcars, output = 'gt') #datasummary(f, data = mtcars, output = 'kableExtra') #datasummary(f, data = mtcars, output = 'flextable') diff --git a/man/get_estimates.Rd b/man/get_estimates.Rd index 696ca646c..926f4e1a0 100644 --- a/man/get_estimates.Rd +++ b/man/get_estimates.Rd @@ -77,7 +77,7 @@ sections below): \itemize{ \item \code{metrics}, \code{estimator}, etc. } -\item \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. +\item \link[tinytable:tt]{tinytable::tt}, \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. }} } \description{ diff --git a/man/get_gof.Rd b/man/get_gof.Rd index ce7bec610..be8506262 100644 --- a/man/get_gof.Rd +++ b/man/get_gof.Rd @@ -21,7 +21,7 @@ get_gof(model, vcov_type = NULL, ...) \itemize{ \item \code{metrics}, \code{estimator}, etc. } -\item \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. +\item \link[tinytable:tt]{tinytable::tt}, \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. }} } \description{ diff --git a/man/get_vcov.Rd b/man/get_vcov.Rd index 3179f42d5..4be62ab7a 100644 --- a/man/get_vcov.Rd +++ b/man/get_vcov.Rd @@ -31,7 +31,7 @@ sections below): \itemize{ \item \code{metrics}, \code{estimator}, etc. } -\item \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. +\item \link[tinytable:tt]{tinytable::tt}, \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. }} } \value{ diff --git a/man/get_vcov.mlm.Rd b/man/get_vcov.mlm.Rd index 325a2cd9b..6053ba188 100644 --- a/man/get_vcov.mlm.Rd +++ b/man/get_vcov.mlm.Rd @@ -31,7 +31,7 @@ sections below): \itemize{ \item \code{metrics}, \code{estimator}, etc. } -\item \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. +\item \link[tinytable:tt]{tinytable::tt}, \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. }} } \value{ diff --git a/man/modelplot.Rd b/man/modelplot.Rd index aabff4f6f..711bfd3c8 100644 --- a/man/modelplot.Rd +++ b/man/modelplot.Rd @@ -110,7 +110,7 @@ plot. This is especially useful to display annotations "behind" the \itemize{ \item \code{metrics}, \code{estimator}, etc. } -\item \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. +\item \link[tinytable:tt]{tinytable::tt}, \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. }} } \description{ diff --git a/man/modelsummary.Rd b/man/modelsummary.Rd index c30438527..eb04cbe3e 100644 --- a/man/modelsummary.Rd +++ b/man/modelsummary.Rd @@ -48,8 +48,8 @@ modelsummary( \item{output}{filename or object type (character string) \itemize{ \item Supported filename extensions: .docx, .html, .tex, .md, .txt, .csv, .xlsx, .png, .jpg -\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. -\item The "default" output format can be set to "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" +\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "typst", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. +\item The "default" output format can be set to "tinytable", "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" \itemize{ \item If the user does not choose a default value, the packages listed above are tried in sequence. \item Session-specific configuration: \code{options("modelsummary_factory_default" = "gt")} @@ -252,7 +252,7 @@ prevent the file from compiling/displaying. This setting does not affect caption \itemize{ \item \code{metrics}, \code{estimator}, etc. } -\item \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. +\item \link[tinytable:tt]{tinytable::tt}, \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. }} } \value{ @@ -261,7 +261,7 @@ a regression table in a format determined by the \code{output} argument. \description{ Create beautiful and customizable tables to summarize several statistical models side-by-side. This function supports dozens of statistical models, -and it can produce tables in HTML, LaTeX, Word, Markdown, PDF, PowerPoint, +and it can produce tables in HTML, LaTeX, Word, Markdown, Typst, PDF, PowerPoint, Excel, RTF, JPG, or PNG. The appearance of the tables can be customized extensively by specifying the \code{output} argument, and by using functions from one of the supported table customization packages: \code{tinytable}, \code{kableExtra}, \code{gt}, @@ -284,6 +284,7 @@ by post-processing it with an external package, you need to choose a different output format and saving mechanism. Unfortunately, the approach differs from package to package: \itemize{ +\item \code{tinytable}: set \code{output="tinytable"}, post-process your table, and use the \code{tinytable::save_tt} function. \item \code{gt}: set \code{output="gt"}, post-process your table, and use the \code{gt::gtsave} function. \item \code{kableExtra}: set \code{output} to your destination format (e.g., "latex", "html", "markdown"), post-process your table, and use \code{kableExtra::save_kable} function. } @@ -342,18 +343,14 @@ The panel-specific option is only used when \code{shape="rbind"} \subsection{Table-making packages}{ -\code{modelsummary} supports 4 table-making packages: \code{kableExtra}, \code{gt}, +\code{modelsummary} supports 6 table-making packages: \code{tinytable}, \code{kableExtra}, \code{gt}, \code{flextable}, \code{huxtable}, and \code{DT}. Some of these packages have overlapping -functionalities. For example, 3 of those packages can export to LaTeX. To -change the default backend used for a specific file format, you can use -the \code{options} function: +functionalities. To change the default backend used for a specific file +format, you can use ' the \code{options} function: \code{options(modelsummary_factory_html = 'kableExtra')} - \code{options(modelsummary_factory_latex = 'gt')} - \code{options(modelsummary_factory_word = 'huxtable')} - \code{options(modelsummary_factory_png = 'gt')} } @@ -377,10 +374,10 @@ and \code{broom}. By default, it uses \code{easystats} first and then falls back \code{broom} in case of failure. You can change the order of priorities or include goodness-of-fit extracted by \emph{both} packages by setting: -\code{options(modelsummary_get = "broom")} - \code{options(modelsummary_get = "easystats")} +\code{options(modelsummary_get = "broom")} + \code{options(modelsummary_get = "all")} } @@ -399,6 +396,21 @@ HTML tables: \code{options(modelsummary_format_numeric_html = "mathjax")} } + +\subsection{LaTeX preamble}{ + +When creating LaTeX via the \code{tinytable} backend (default in version 2.0.0 and later), it is useful to include the following commands in the LaTeX preamble of your documents. Note that they are added automatically when compiling Rmarkdown or Quarto documents. + +\\usepackage\{tabularray\} +\\usepackage\{float\} +\\usepackage\{graphicx\} +\\usepackage\{codehigh\} +\\usepackage\link{normalem}\{ulem\} +\\UseTblrLibrary\{booktabs\} +\\newcommand\{\\tinytableTabularrayUnderline\}\link{1}\{\\underline\{#1\}\} +\\newcommand\{\\tinytableTabularrayStrikeout\}\link{1}\{\\sout\{#1\}\} +\\NewTableCommand\{\\tinytableDefineColor\}\link{3}\{\\definecolor\{#1\}\{#2\}\{#3\}\} +} } \section{Parallel computation}{ diff --git a/man/msummary.Rd b/man/msummary.Rd index e0de87ef7..95b2b86ba 100644 --- a/man/msummary.Rd +++ b/man/msummary.Rd @@ -48,8 +48,8 @@ msummary( \item{output}{filename or object type (character string) \itemize{ \item Supported filename extensions: .docx, .html, .tex, .md, .txt, .csv, .xlsx, .png, .jpg -\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. -\item The "default" output format can be set to "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" +\item Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "typst", "data.frame", "tinytable", "gt", "kableExtra", "huxtable", "flextable", "DT", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the \code{modelsummary} function. +\item The "default" output format can be set to "tinytable", "kableExtra", "gt", "flextable", "huxtable", "DT", or "markdown" \itemize{ \item If the user does not choose a default value, the packages listed above are tried in sequence. \item Session-specific configuration: \code{options("modelsummary_factory_default" = "gt")} @@ -252,7 +252,7 @@ prevent the file from compiling/displaying. This setting does not affect caption \itemize{ \item \code{metrics}, \code{estimator}, etc. } -\item \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. +\item \link[tinytable:tt]{tinytable::tt}, \link[kableExtra:kbl]{kableExtra::kbl} or \link[gt:gt]{gt::gt} draw tables, depending on the value of the \code{output} argument. }} } \value{ @@ -261,7 +261,7 @@ a regression table in a format determined by the \code{output} argument. \description{ Create beautiful and customizable tables to summarize several statistical models side-by-side. This function supports dozens of statistical models, -and it can produce tables in HTML, LaTeX, Word, Markdown, PDF, PowerPoint, +and it can produce tables in HTML, LaTeX, Word, Markdown, Typst, PDF, PowerPoint, Excel, RTF, JPG, or PNG. The appearance of the tables can be customized extensively by specifying the \code{output} argument, and by using functions from one of the supported table customization packages: \code{tinytable}, \code{kableExtra}, \code{gt}, @@ -284,6 +284,7 @@ by post-processing it with an external package, you need to choose a different output format and saving mechanism. Unfortunately, the approach differs from package to package: \itemize{ +\item \code{tinytable}: set \code{output="tinytable"}, post-process your table, and use the \code{tinytable::save_tt} function. \item \code{gt}: set \code{output="gt"}, post-process your table, and use the \code{gt::gtsave} function. \item \code{kableExtra}: set \code{output} to your destination format (e.g., "latex", "html", "markdown"), post-process your table, and use \code{kableExtra::save_kable} function. } @@ -342,18 +343,14 @@ The panel-specific option is only used when \code{shape="rbind"} \subsection{Table-making packages}{ -\code{modelsummary} supports 4 table-making packages: \code{kableExtra}, \code{gt}, +\code{modelsummary} supports 6 table-making packages: \code{tinytable}, \code{kableExtra}, \code{gt}, \code{flextable}, \code{huxtable}, and \code{DT}. Some of these packages have overlapping -functionalities. For example, 3 of those packages can export to LaTeX. To -change the default backend used for a specific file format, you can use -the \code{options} function: +functionalities. To change the default backend used for a specific file +format, you can use ' the \code{options} function: \code{options(modelsummary_factory_html = 'kableExtra')} - \code{options(modelsummary_factory_latex = 'gt')} - \code{options(modelsummary_factory_word = 'huxtable')} - \code{options(modelsummary_factory_png = 'gt')} } @@ -377,10 +374,10 @@ and \code{broom}. By default, it uses \code{easystats} first and then falls back \code{broom} in case of failure. You can change the order of priorities or include goodness-of-fit extracted by \emph{both} packages by setting: -\code{options(modelsummary_get = "broom")} - \code{options(modelsummary_get = "easystats")} +\code{options(modelsummary_get = "broom")} + \code{options(modelsummary_get = "all")} } @@ -399,6 +396,21 @@ HTML tables: \code{options(modelsummary_format_numeric_html = "mathjax")} } + +\subsection{LaTeX preamble}{ + +When creating LaTeX via the \code{tinytable} backend (default in version 2.0.0 and later), it is useful to include the following commands in the LaTeX preamble of your documents. Note that they are added automatically when compiling Rmarkdown or Quarto documents. + +\\usepackage\{tabularray\} +\\usepackage\{float\} +\\usepackage\{graphicx\} +\\usepackage\{codehigh\} +\\usepackage\link{normalem}\{ulem\} +\\UseTblrLibrary\{booktabs\} +\\newcommand\{\\tinytableTabularrayUnderline\}\link{1}\{\\underline\{#1\}\} +\\newcommand\{\\tinytableTabularrayStrikeout\}\link{1}\{\\sout\{#1\}\} +\\NewTableCommand\{\\tinytableDefineColor\}\link{3}\{\\definecolor\{#1\}\{#2\}\{#3\}\} +} } \section{Parallel computation}{