@@ -854,3 +854,73 @@ plot.equivalence_test_lm <- function(x, ...) {
854854 insight :: check_if_installed(" see" )
855855 NextMethod()
856856}
857+
858+
859+ # helper for print_html / print_md --------------------
860+
861+ .print_equivalence_test_lm <- function (
862+ x ,
863+ digits = 2 ,
864+ ci_brackets = c(" (" , " )" ),
865+ zap_small = FALSE ,
866+ format = " markdown" ,
867+ ...
868+ ) {
869+ rule <- attributes(x )$ rule
870+ rope <- attributes(x )$ rope
871+
872+ if (is.null(rule )) {
873+ table_caption <- " Test for Practical Equivalence"
874+ } else if (rule == " cet" ) {
875+ table_caption <- " Conditional Equivalence Testing"
876+ } else if (rule == " classic" ) {
877+ table_caption <- " TOST-test for Practical Equivalence"
878+ } else {
879+ table_caption <- " Test for Practical Equivalence"
880+ }
881+
882+ if (" Component" %in% colnames(x )) {
883+ x <- x [x $ Component %in% c(" conditional" , " count" ), ]
884+ }
885+
886+ formatted_table <- insight :: format_table(
887+ x ,
888+ pretty_names = TRUE ,
889+ digits = digits ,
890+ ci_width = NULL ,
891+ ci_brackets = ci_brackets ,
892+ zap_small = zap_small ,
893+ ...
894+ )
895+
896+ colnames(formatted_table )[which(colnames(formatted_table ) == " Equivalence (ROPE)" )] <- " H0"
897+ formatted_table $ ROPE <- NULL
898+
899+ # col_order <- c("Parameter", "H0", "% in ROPE", colnames(formatted_table)[grepl(" CI$", colnames(formatted_table))])
900+ # col_order <- c(col_order, setdiff(colnames(formatted_table), col_order))
901+ # formatted_table <- formatted_table[col_order]
902+
903+ # replace brackets by parenthesis
904+ if (! is.null(ci_brackets ) && " Parameter" %in% colnames(formatted_table )) {
905+ formatted_table $ Parameter <- gsub(" [" , ci_brackets [1 ], formatted_table $ Parameter , fixed = TRUE )
906+ formatted_table $ Parameter <- gsub(" ]" , ci_brackets [2 ], formatted_table $ Parameter , fixed = TRUE )
907+ }
908+
909+ if (! is.null(rope )) {
910+ names(formatted_table )[names(formatted_table ) == " % in ROPE" ] <- sprintf(
911+ " %% in ROPE (%.*f, %.*f)" ,
912+ digits ,
913+ rope [1 ],
914+ digits ,
915+ rope [2 ]
916+ ) # nolint
917+ }
918+
919+ insight :: export_table(
920+ formatted_table ,
921+ format = format ,
922+ caption = table_caption ,
923+ align = " firstleft" ,
924+ ...
925+ )
926+ }
0 commit comments