-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathprint_html.R
55 lines (43 loc) · 1.77 KB
/
print_html.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#' @export
print_html.estimate_contrasts <- function(x,
select = getOption("modelbased_select", NULL),
include_grid = getOption("modelbased_include_grid", FALSE),
full_labels = TRUE,
...) {
# copy original
out <- x
# get attributes, but remove some of them - else, matching attribute fails
attr <- attributes(x)
attr <- attr[setdiff(names(attr), c("names", "row.names"))]
# format table
formatted_table <- format(out, select = select, format = "html", include_grid = include_grid, ...)
attributes(formatted_table) <- utils::modifyList(attributes(formatted_table), attr)
# remove redundant labels, for "by" variables
formatted_table <- .remove_redundant_labels(x, formatted_table, full_labels)
# set alignment, left-align first and non-numerics
align <- .align_columns(x, formatted_table)
# update footer
table_footer <- attributes(formatted_table)$table_footer
if (!is.null(table_footer)) {
table_footer <- insight::compact_character(strsplit(table_footer, "\\n")[[1]])
attr(formatted_table, "table_footer") <- paste(table_footer, collapse = "<br>")
}
insight::export_table(
formatted_table,
format = "html",
align = align,
...
)
}
#' @export
print_html.estimate_means <- print_html.estimate_contrasts
#' @export
print_html.estimate_slopes <- print_html.estimate_contrasts
#' @export
print_html.estimate_smooth <- print_html.estimate_contrasts
#' @export
print_html.estimate_predicted <- print_html.estimate_contrasts
#' @export
print_html.visualisation_matrix <- print_html.estimate_contrasts
#' @export
print_html.estimate_grouplevel <- print_html.estimate_contrasts