@@ -23,14 +23,10 @@ print_html.parameters_model <- function(x,
2323 line_padding = 4 ,
2424 column_labels = NULL ,
2525 include_reference = FALSE ,
26- engine = " gt" ,
2726 verbose = TRUE ,
2827 ... ) {
2928 # which engine?
30- engine <- insight :: validate_argument(
31- getOption(" easystats_html_engine" , engine ),
32- c(" gt" , " default" , " tt" )
33- )
29+ engine <- .check_format_backend(... )
3430
3531 # line separator - for tinytable, we have no specific line separator,
3632 # because the output format is context-dependent
@@ -123,7 +119,7 @@ print_html.parameters_model <- function(x,
123119
124120 out <- insight :: export_table(
125121 formatted_table ,
126- format = ifelse(identical( engine , " tt " ), " tt " , " html " ) ,
122+ format = engine ,
127123 caption = table_caption ,
128124 subtitle = subtitle ,
129125 footer = footer ,
@@ -170,7 +166,6 @@ print_html.compare_parameters <- function(x,
170166 font_size = " 100%" ,
171167 line_padding = 4 ,
172168 column_labels = NULL ,
173- engine = " gt" ,
174169 ... ) {
175170 # check if user supplied digits attributes
176171 if (missing(digits )) {
@@ -191,10 +186,7 @@ print_html.compare_parameters <- function(x,
191186 }
192187
193188 # which engine?
194- engine <- insight :: validate_argument(
195- getOption(" easystats_html_engine" , engine ),
196- c(" gt" , " default" , " tt" )
197- )
189+ engine <- .check_format_backend(... )
198190
199191 # line separator - for tinytable, we have no specific line separator,
200192 # because the output format is context-dependent
@@ -261,7 +253,7 @@ print_html.compare_parameters <- function(x,
261253
262254 out <- insight :: export_table(
263255 formatted_table ,
264- format = ifelse(identical( engine , " tt " ), " tt " , " html " ) ,
256+ format = engine ,
265257 caption = caption , # TODO: get rid of NOTE
266258 subtitle = subtitle ,
267259 footer = footer ,
@@ -297,14 +289,7 @@ print_html.parameters_efa <- function(x,
297289 sort = FALSE ,
298290 threshold = NULL ,
299291 labels = NULL ,
300- engine = " gt" ,
301292 ... ) {
302- # which engine?
303- engine <- insight :: validate_argument(
304- getOption(" easystats_html_engine" , engine ),
305- c(" gt" , " default" , " tt" )
306- )
307-
308293 # extract attributes
309294 if (is.null(threshold )) {
310295 threshold <- attributes(x )$ threshold
@@ -313,7 +298,7 @@ print_html.parameters_efa <- function(x,
313298 x ,
314299 threshold = threshold ,
315300 sort = sort ,
316- format = ifelse(identical( engine , " tt " ), " tt " , " html" ) ,
301+ format = " html" ,
317302 digits = digits ,
318303 labels = labels ,
319304 ...
@@ -325,12 +310,9 @@ print_html.parameters_pca <- print_html.parameters_efa
325310
326311
327312# ' @export
328- print_html.parameters_efa_summary <- function (x , digits = 3 , engine = " gt " , ... ) {
313+ print_html.parameters_efa_summary <- function (x , digits = 3 , ... ) {
329314 # html engine?
330- engine <- insight :: validate_argument(
331- getOption(" easystats_html_engine" , engine ),
332- c(" gt" , " default" , " tt" )
333- )
315+ engine <- .check_format_backend(... )
334316
335317 table_caption <- " (Explained) Variance of Components"
336318
@@ -354,7 +336,7 @@ print_html.parameters_efa_summary <- function(x, digits = 3, engine = "gt", ...)
354336 insight :: export_table(
355337 x ,
356338 digits = digits ,
357- format = ifelse(identical( engine , " tt " ), " tt " , " html " ) ,
339+ format = engine ,
358340 caption = table_caption ,
359341 align = " firstleft"
360342 )
@@ -372,7 +354,6 @@ print_html.parameters_p_function <- function(x,
372354 ci_width = " auto" ,
373355 ci_brackets = c(" (" , " )" ),
374356 pretty_names = TRUE ,
375- engine = " gt" ,
376357 ... ) {
377358 .print_p_function(
378359 x ,
@@ -381,7 +362,6 @@ print_html.parameters_p_function <- function(x,
381362 ci_brackets ,
382363 pretty_names ,
383364 format = " html" ,
384- engine = engine ,
385365 ...
386366 )
387367}
@@ -457,3 +437,14 @@ print_html.parameters_p_function <- function(x,
457437 )
458438 out
459439}
440+
441+
442+ # we allow exporting HTML format based on "gt" or "tinytable"
443+ .check_format_backend <- function (... ) {
444+ dots <- list (... )
445+ if (identical(dots $ backend , " tt" )) {
446+ " tt"
447+ } else {
448+ " html"
449+ }
450+ }
0 commit comments