From e05fb335b4287e05883f71511438b08d36813006 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Mar 2024 19:18:55 +0100 Subject: [PATCH] docs, option --- R/print.parameters_model.R | 18 +++++++++++------- R/print_html.R | 2 +- man/model_parameters.Rd | 3 +++ man/print.parameters_model.Rd | 3 +++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/R/print.parameters_model.R b/R/print.parameters_model.R index b707ed422..7fd638de9 100644 --- a/R/print.parameters_model.R +++ b/R/print.parameters_model.R @@ -137,6 +137,10 @@ #' default for the `select` argument. See argument's documentation for available #' options. #' +#' - `easystats_html_engine`: `options(easystats_html_engine = "gt")` will set +#' the default HTML engine for tables to `gt`, i.e. the _gt_ package is used to +#' create HTML tables. If set to `tt`, the _tinytable_ package is used. +#' #' @details `summary()` is a convenient shortcut for #' `print(object, select = "minimal", show_sigma = TRUE, show_formula = TRUE)`. #' @@ -412,7 +416,7 @@ print.parameters_random <- function(x, digits = 2, ...) { show_formula = FALSE, format = "text") { # get attributes - sigma <- attributes(x)$sigma + model_sigma <- attributes(x)$sigma show_summary <- isTRUE(attributes(x)$show_summary) verbose <- .additional_arguments(x, "verbose", TRUE) @@ -423,7 +427,7 @@ print.parameters_random <- function(x, digits = 2, ...) { show_r2 <- .additional_arguments(x, "show_summary", FALSE) # set defaults, if necessary - if (is.null(sigma)) { + if (is.null(model_sigma)) { show_sigma <- FALSE } @@ -522,10 +526,10 @@ print.parameters_random <- function(x, digits = 2, ...) { random_params$Term[is.na(random_params$Term)] <- "" random_params$SD[is.na(random_params$SD)] <- "" - non_empty <- random_params$Term != "" & random_params$Type != "" + non_empty <- random_params$Term != "" & random_params$Type != "" # nolint random_params$Line[non_empty] <- sprintf("%s (%s)", random_params$Type[non_empty], random_params$Term[non_empty]) - non_empty <- random_params$Term != "" & random_params$Type == "" + non_empty <- random_params$Term != "" & random_params$Type == "" # nolint random_params$Line[non_empty] <- sprintf("%s", random_params$Term[non_empty]) # final fix, indentions @@ -567,9 +571,9 @@ print.parameters_random <- function(x, digits = 2, ...) { col_width <- rep(NA, length(shared_cols)) for (i in seq_along(shared_cols)) { col_width[i] <- max(unlist(lapply(formatted_table, function(j) { - col <- j[[shared_cols[i]]] - if (!is.null(col)) { - max(nchar(col)) + column <- j[[shared_cols[i]]] + if (!is.null(column)) { + max(nchar(column)) } else { NA } diff --git a/R/print_html.R b/R/print_html.R index 0b10cef6d..2998b00d0 100644 --- a/R/print_html.R +++ b/R/print_html.R @@ -171,7 +171,7 @@ print_html.compare_parameters <- function(x, } # markdown engine? - engine <- match.arg(engine, c("gt", "default", "tt")) + engine <- match.arg(getOption("easystats_html_engine", engine), c("gt", "default", "tt")) # for tiny table, we can just call print_md() if (engine == "tt") { diff --git a/man/model_parameters.Rd b/man/model_parameters.Rd index 70e012556..d124d2cc9 100644 --- a/man/model_parameters.Rd +++ b/man/model_parameters.Rd @@ -374,6 +374,9 @@ will replace the interaction mark (by default, \code{*}) with the related charac \item \code{parameters_select}: \verb{options(parameters_select = )} will set the default for the \code{select} argument. See argument's documentation for available options. +\item \code{easystats_html_engine}: \code{options(easystats_html_engine = "gt")} will set +the default HTML engine for tables to \code{gt}, i.e. the \emph{gt} package is used to +create HTML tables. If set to \code{tt}, the \emph{tinytable} package is used. } } diff --git a/man/print.parameters_model.Rd b/man/print.parameters_model.Rd index 5b602b1d9..18bec59c7 100644 --- a/man/print.parameters_model.Rd +++ b/man/print.parameters_model.Rd @@ -185,6 +185,9 @@ will replace the interaction mark (by default, \code{*}) with the related charac \item \code{parameters_select}: \verb{options(parameters_select = )} will set the default for the \code{select} argument. See argument's documentation for available options. +\item \code{easystats_html_engine}: \code{options(easystats_html_engine = "gt")} will set +the default HTML engine for tables to \code{gt}, i.e. the \emph{gt} package is used to +create HTML tables. If set to \code{tt}, the \emph{tinytable} package is used. } }