Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions R/display.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
align = align,
font_size = font_size,
line_padding = line_padding,
engine = ifelse(format == "tt", "tt", "gt")
backend = ifelse(format == "tt", "tt", "html")
)
)
do.call(print_html, c(fun_args, list(...)))
Expand Down Expand Up @@ -189,7 +189,7 @@
column_labels = column_labels,
font_size = font_size,
line_padding = line_padding,
engine = ifelse(format == "tt", "tt", "gt")
backend = ifelse(format == "tt", "tt", "html")
)
)
do.call(print_html, c(fun_args, list(...)))
Expand Down Expand Up @@ -219,7 +219,7 @@
ci_digits = ci_digits,
p_digits = p_digits,
ci_brackets = ci_brackets,
engine = ifelse(format == "tt", "tt", "gt")
backend = ifelse(format == "tt", "tt", "html")
)

if (format %in% c("html", "tt")) {
Expand All @@ -237,7 +237,7 @@
#' @export
display.parameters_efa_summary <- function(object, format = "markdown", digits = 3, ...) {
format <- insight::validate_argument(format, c("markdown", "html", "md", "tt"))
fun_args <- list(x = object, digits = digits, engine = ifelse(format == "tt", "tt", "gt"))
fun_args <- list(x = object, digits = digits, backend = ifelse(format == "tt", "tt", "html"))

if (format %in% c("html", "tt")) {
do.call(print_html, c(fun_args, list(...)))
Expand All @@ -256,7 +256,7 @@
#' @inheritParams model_parameters.principal
#' @rdname display.parameters_model
#' @export
display.parameters_efa <- function(object, format = "markdown", digits = 2, sort = FALSE, threshold = NULL, labels = NULL, ...) {

Check warning on line 259 in R/display.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/display.R,line=259,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 129 characters.
format <- insight::validate_argument(format, c("markdown", "html", "md", "tt"))

fun_args <- list(
Expand All @@ -265,7 +265,7 @@
sort = sort,
threshold = threshold,
labels = labels,
engine = ifelse(format == "tt", "tt", "gt")
backend = ifelse(format == "tt", "tt", "html")
)

if (format %in% c("html", "tt")) {
Expand Down Expand Up @@ -310,7 +310,7 @@
ci_width = ci_width,
ci_brackets = ci_brackets,
pretty_names = pretty_names,
engine = ifelse(format == "tt", "tt", "gt")
backend = ifelse(format == "tt", "tt", "html")
)

if (format %in% c("html", "tt")) {
Expand Down
6 changes: 1 addition & 5 deletions R/p_function.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
#' A non-significant p-value could occur because the test hypothesis is false,
#' but could also be the result of any of the model assumptions being incorrect.
#'
#' \if{html}{\cr \figure{unconditional_interpretation.png}{options: alt="Conditional versus unconditional interpretations of P-values"} \cr}

Check warning on line 80 in R/p_function.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/p_function.R,line=80,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 140 characters.
#'
#' "Emphasizing unconditional interpretations helps avoid overconfident and
#' misleading inferences in light of uncertainties about the assumptions used
Expand Down Expand Up @@ -443,13 +443,9 @@
ci_brackets = c("(", ")"),
pretty_names = TRUE,
format = "html",
engine = "gt",
...) {
# which engine?
engine <- insight::validate_argument(
getOption("easystats_html_engine", engine),
c("gt", "default", "tt")
)
engine <- .check_format_backend(...)

formatted_table <- format(
x,
Expand Down
49 changes: 21 additions & 28 deletions R/print_html.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@
line_padding = 4,
column_labels = NULL,
include_reference = FALSE,
engine = "gt",
verbose = TRUE,
...) {
# which engine?
engine <- insight::validate_argument(
getOption("easystats_html_engine", engine),
c("gt", "default", "tt")
)
engine <- .check_format_backend(...)

# line separator - for tinytable, we have no specific line separator,
# because the output format is context-dependent
Expand Down Expand Up @@ -123,7 +119,7 @@

out <- insight::export_table(
formatted_table,
format = ifelse(identical(engine, "tt"), "tt", "html"),
format = engine,
caption = table_caption,
subtitle = subtitle,
footer = footer,
Expand Down Expand Up @@ -170,7 +166,6 @@
font_size = "100%",
line_padding = 4,
column_labels = NULL,
engine = "gt",
...) {
# check if user supplied digits attributes
if (missing(digits)) {
Expand All @@ -191,10 +186,7 @@
}

# which engine?
engine <- insight::validate_argument(
getOption("easystats_html_engine", engine),
c("gt", "default", "tt")
)
engine <- .check_format_backend(...)

# line separator - for tinytable, we have no specific line separator,
# because the output format is context-dependent
Expand Down Expand Up @@ -227,7 +219,7 @@
# --------------------------------------------------------------------------

model_groups <- NULL
by <- NULL

Check warning on line 222 in R/print_html.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/print_html.R,line=222,col=3,[object_overwrite_linter] 'by' is an exported object from package 'base'. Avoid re-using such symbols.

# find columns that contain model names, which we want to group
models <- setdiff(
Expand All @@ -251,17 +243,17 @@
}
}
if ("Component" %in% colnames(formatted_table)) {
by <- c(by, "Component")

Check warning on line 246 in R/print_html.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/print_html.R,line=246,col=5,[object_overwrite_linter] 'by' is an exported object from package 'base'. Avoid re-using such symbols.
}
if ("Effects" %in% colnames(formatted_table)) {
by <- c(by, "Effects")

Check warning on line 249 in R/print_html.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/print_html.R,line=249,col=5,[object_overwrite_linter] 'by' is an exported object from package 'base'. Avoid re-using such symbols.
}

# export table ------------------------------------------------------------

out <- insight::export_table(
formatted_table,
format = ifelse(identical(engine, "tt"), "tt", "html"),
format = engine,
caption = caption, # TODO: get rid of NOTE
subtitle = subtitle,
footer = footer,
Expand Down Expand Up @@ -297,14 +289,7 @@
sort = FALSE,
threshold = NULL,
labels = NULL,
engine = "gt",
...) {
# which engine?
engine <- insight::validate_argument(
getOption("easystats_html_engine", engine),
c("gt", "default", "tt")
)

# extract attributes
if (is.null(threshold)) {
threshold <- attributes(x)$threshold
Expand All @@ -313,9 +298,10 @@
x,
threshold = threshold,
sort = sort,
format = ifelse(identical(engine, "tt"), "tt", "html"),
format = "html",
digits = digits,
labels = labels,
backend = .check_format_backend(...),
...
)
}
Expand All @@ -325,12 +311,9 @@


#' @export
print_html.parameters_efa_summary <- function(x, digits = 3, engine = "gt", ...) {
print_html.parameters_efa_summary <- function(x, digits = 3, ...) {
# html engine?
engine <- insight::validate_argument(
getOption("easystats_html_engine", engine),
c("gt", "default", "tt")
)
engine <- .check_format_backend(...)

table_caption <- "(Explained) Variance of Components"

Expand All @@ -354,7 +337,7 @@
insight::export_table(
x,
digits = digits,
format = ifelse(identical(engine, "tt"), "tt", "html"),
format = engine,
caption = table_caption,
align = "firstleft"
)
Expand All @@ -372,7 +355,6 @@
ci_width = "auto",
ci_brackets = c("(", ")"),
pretty_names = TRUE,
engine = "gt",
...) {
.print_p_function(
x,
Expand All @@ -381,7 +363,7 @@
ci_brackets,
pretty_names,
format = "html",
engine = engine,
backend = .check_format_backend(...),
...
)
}
Expand Down Expand Up @@ -457,3 +439,14 @@
)
out
}


# we allow exporting HTML format based on "gt" or "tinytable"
.check_format_backend <- function(...) {
dots <- list(...)
if (is.null(dots) || !identical(dots$backend, "tt")) {
"html"
} else {
"tt"
}
}
10 changes: 4 additions & 6 deletions R/standardize_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
#' @family standardize
#' @family effect size indices
#'
#' @seealso See also [package vignette](https://easystats.github.io/parameters/articles/standardize_parameters_effsize.html).

Check warning on line 128 in R/standardize_parameters.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/standardize_parameters.R,line=128,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 125 characters.
#'
#' @examples
#' model <- lm(len ~ supp * dose, data = ToothGrowth)
Expand Down Expand Up @@ -260,7 +260,7 @@
colnames(pars)[colnames(pars) == "Coefficient"] <- gsub(" ", "_", coefficient_name, fixed = TRUE)
}

i <- colnames(pars) %in% c("Coefficient", "Median", "Mean", "MAP", "Odds_Ratio", "Risk_Ratio", "IRR", "Prevalence_Ratio")

Check warning on line 263 in R/standardize_parameters.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/standardize_parameters.R,line=263,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 123 characters.
colnames(pars)[i] <- paste0("Std_", colnames(pars)[i])

## SE attribute?
Expand Down Expand Up @@ -549,14 +549,12 @@
}

#' @export
print_html.parameters_standardized <- function(x, digits = 2, engine = "gt", ...) {
print_html.parameters_standardized <- function(x, digits = 2, ...) {
# which engine?
engine <- insight::validate_argument(
getOption("easystats_html_engine", engine),
c("gt", "default", "tt")
)
engine <- .check_format_backend(...)

x_fmt <- format(x, digits = digits, output = "html", ...)
insight::export_table(x_fmt, format = ifelse(identical(engine, "tt"), "tt", "html"), ...)
insight::export_table(x_fmt, format = engine, ...)
}


Expand Down
7 changes: 2 additions & 5 deletions R/utils_pca_efa.R
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
# extract model
model <- attributes(x)$model
if (!is.null(model)) {
stats <- data.frame(

Check warning on line 320 in R/utils_pca_efa.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/utils_pca_efa.R,line=320,col=14,[strings_as_factors_linter] Supply an explicit value for stringsAsFactors for this code to work before and after R version 4.0.
Statistic = c("Alpha", "G.6", "Omega (hierarchical)", "Omega (asymptotic H)", "Omega (total)"),
Coefficient = c(model$alpha, model$G6, model$omega_h, model$omega.lim, model$omega.tot)
)
Expand Down Expand Up @@ -363,12 +363,9 @@
}


.print_parameters_cfa_efa <- function(x, threshold, sort, format, digits, labels, engine = "gt", ...) {
.print_parameters_cfa_efa <- function(x, threshold, sort, format, digits, labels, ...) {
# html engine?
engine <- insight::validate_argument(
getOption("easystats_html_engine", engine),
c("gt", "default", "tt")
)
engine <- .check_format_backend(...)

# Method
if (inherits(x, "parameters_pca")) {
Expand Down
Loading