Skip to content

Commit c21d5c3

Browse files
committed
update
1 parent b825709 commit c21d5c3

File tree

5 files changed

+43
-52
lines changed

5 files changed

+43
-52
lines changed

R/display.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ display.parameters_sem <- function(object,
216216
digits = digits,
217217
ci_digits = ci_digits,
218218
p_digits = p_digits,
219-
ci_brackets = ci_brackets
219+
ci_brackets = ci_brackets,
220+
engine = ifelse(format == "tt", "tt", "gt")
220221
)
221222

222223
if (format %in% c("html", "tt")) {
@@ -234,7 +235,7 @@ display.parameters_sem <- function(object,
234235
#' @export
235236
display.parameters_efa_summary <- function(object, format = "markdown", digits = 3, ...) {
236237
format <- insight::validate_argument(format, c("markdown", "html", "md", "tt"))
237-
fun_args <- list(x = object, digits = digits)
238+
fun_args <- list(x = object, digits = digits, engine = ifelse(format == "tt", "tt", "gt"))
238239

239240
if (format %in% c("html", "tt")) {
240241
do.call(print_html, c(fun_args, list(...)))
@@ -261,7 +262,8 @@ display.parameters_efa <- function(object, format = "markdown", digits = 2, sort
261262
digits = digits,
262263
sort = sort,
263264
threshold = threshold,
264-
labels = labels
265+
labels = labels,
266+
engine = ifelse(format == "tt", "tt", "gt")
265267
)
266268

267269
if (format %in% c("html", "tt")) {

R/print_html.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ print_html.compare_parameters <- function(x,
186186
select <- attributes(x)$output_style
187187
}
188188

189-
# markdown engine?
189+
# which engine?
190190
engine <- insight::validate_argument(
191191
getOption("easystats_html_engine", engine),
192192
c("gt", "default", "tt")
@@ -291,6 +291,12 @@ print_html.parameters_efa <- function(x,
291291
labels = NULL,
292292
engine = "gt",
293293
...) {
294+
# which engine?
295+
engine <- insight::validate_argument(
296+
getOption("easystats_html_engine", engine),
297+
c("gt", "default", "tt")
298+
)
299+
294300
# extract attributes
295301
if (is.null(threshold)) {
296302
threshold <- attributes(x)$threshold
@@ -299,7 +305,7 @@ print_html.parameters_efa <- function(x,
299305
x,
300306
threshold = threshold,
301307
sort = sort,
302-
format = engine,
308+
format = ifelse(identical(engine, "tt"), "tt", "html"),
303309
digits = digits,
304310
labels = labels,
305311
...

R/print_md.R

Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ print_md.parameters_model <- function(x,
9898
}
9999
}
100100

101-
102101
insight::export_table(
103102
formatted_table,
104103
format = "markdown",
@@ -134,7 +133,6 @@ print_md.compare_parameters <- function(x,
134133
ci_brackets = c("(", ")"),
135134
zap_small = FALSE,
136135
groups = NULL,
137-
engine = "tt",
138136
...) {
139137
# check if user supplied digits attributes
140138
if (missing(digits)) {
@@ -155,9 +153,6 @@ print_md.compare_parameters <- function(x,
155153
groups <- attributes(x)$parameter_groups
156154
}
157155

158-
# markdown engine?
159-
engine <- insight::validate_argument(engine, c("tt", "default"))
160-
161156
formatted_table <- format(
162157
x,
163158
select = select,
@@ -169,8 +164,7 @@ print_md.compare_parameters <- function(x,
169164
ci_brackets = ci_brackets,
170165
format = "markdown",
171166
zap_small = zap_small,
172-
groups = groups,
173-
engine = engine
167+
groups = groups
174168
)
175169

176170
# replace brackets by parenthesis
@@ -179,36 +173,13 @@ print_md.compare_parameters <- function(x,
179173
formatted_table$Parameter <- gsub("]", ci_brackets[2], formatted_table$Parameter, fixed = TRUE)
180174
}
181175

182-
if (identical(engine, "tt")) {
183-
# retrieve output format - print_md() may be called from print_html()
184-
dots <- list(...)
185-
if (identical(dots$outformat, "html")) {
186-
outformat <- "html"
187-
} else {
188-
outformat <- "markdown"
189-
}
190-
191-
col_names <- gsub("(.*) \\((.*)\\)$", "\\2", colnames(formatted_table))
192-
col_groups <- sapply(attributes(x)$model_names, function(i) which(i == col_names), simplify = FALSE)
193-
colnames(formatted_table) <- gsub("(.*) \\((.*)\\)$", "\\1", colnames(formatted_table))
194-
195-
insight::export_table(
196-
formatted_table,
197-
format = "tt",
198-
caption = caption,
199-
subtitle = subtitle,
200-
footer = footer,
201-
column_groups = col_groups
202-
)
203-
} else {
204-
insight::export_table(
205-
formatted_table,
206-
format = "markdown",
207-
caption = caption,
208-
subtitle = subtitle,
209-
footer = footer
210-
)
211-
}
176+
insight::export_table(
177+
formatted_table,
178+
format = "markdown",
179+
caption = caption,
180+
subtitle = subtitle,
181+
footer = footer
182+
)
212183
}
213184

214185

@@ -317,11 +288,13 @@ print_md.parameters_omega <- print_md.parameters_efa
317288
# Equivalence test ----------------------------
318289

319290
#' @export
320-
print_md.equivalence_test_lm <- function(x,
321-
digits = 2,
322-
ci_brackets = c("(", ")"),
323-
zap_small = FALSE,
324-
...) {
291+
print_md.equivalence_test_lm <- function(
292+
x,
293+
digits = 2,
294+
ci_brackets = c("(", ")"),
295+
zap_small = FALSE,
296+
...
297+
) {
325298
rule <- attributes(x)$rule
326299
rope <- attributes(x)$rope
327300

@@ -363,8 +336,19 @@ print_md.equivalence_test_lm <- function(x,
363336
}
364337

365338
if (!is.null(rope)) {
366-
names(formatted_table)[names(formatted_table) == "% in ROPE"] <- sprintf("%% in ROPE (%.*f, %.*f)", digits, rope[1], digits, rope[2]) # nolint
339+
names(formatted_table)[names(formatted_table) == "% in ROPE"] <- sprintf(
340+
"%% in ROPE (%.*f, %.*f)",
341+
digits,
342+
rope[1],
343+
digits,
344+
rope[2]
345+
) # nolint
367346
}
368347

369-
insight::export_table(formatted_table, format = "markdown", caption = table_caption, align = "firstleft")
348+
insight::export_table(
349+
formatted_table,
350+
format = "markdown",
351+
caption = table_caption,
352+
align = "firstleft"
353+
)
370354
}

R/utils_pca_efa.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ print.parameters_omega_summary <- function(x, ...) {
426426
}
427427

428428
# set engine for html format
429-
if (format == "html") {
430-
format <- ifelse(identical(engine, "tt"), "tt", "html")
429+
if (format == "html" && identical(engine, "tt")) {
430+
format <- "tt"
431431
}
432432

433433
insight::export_table(

man/print.compare_parameters.Rd

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)