Skip to content

Commit

Permalink
format symbols in colnames for format_table
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Sep 22, 2022
1 parent 36f5e63 commit 2cf02d5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: insight
Title: Easy Access to Model Information for Various Model Objects
Version: 0.18.4.3
Version: 0.18.4.4
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
29 changes: 26 additions & 3 deletions R/format_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ format_table <- function(x,
x <- .format_performance_columns(x, digits, ic_digits, zap_small, use_symbols)


# format symbols in column names, if any left
x <- .format_symbols(x, use_symbols)


# Format remaining columns
other_cols <- names(x)[sapply(x, is.numeric)]
x[other_cols[other_cols %in% names(x)]] <- format_value(
Expand Down Expand Up @@ -320,12 +324,12 @@ format_table <- function(x,
names(x)[names(x) == "Eta2_generalized"] <- "\u03B7\u00b2 (generalized)"
names(x)[names(x) == "Epsilon2"] <- "\u03b5\u00b2"
names(x)[names(x) == "Epsilon2_partial"] <- "\u03b5\u00b2 (partial)"
names(x)[names(x) == "Omega2"] <- "u03C9\u00b2"
names(x)[names(x) == "Omega2_partial"] <- "u03C9\u00b2 (partial)"
names(x)[names(x) == "Omega2"] <- "\u03C9\u00b2"
names(x)[names(x) == "Omega2_partial"] <- "\u03C9\u00b2 (partial)"
names(x)[names(x) == "Cohens_f2"] <- "Cohen's f\u00b2"
names(x)[names(x) == "Cohens_f2"] <- "Cohen's f\u00b2 (partial)"
names(x)[names(x) == "rank_epsilon_squared"] <- "\u03B5\u00b2(R)"
names(x)[names(x) == "rank_eta_squared"] <- "u03B7\u00b2(H)"
names(x)[names(x) == "rank_eta_squared"] <- "\u03B7\u00b2(H)"
} else {
names(x)[names(x) == "Glass_delta"] <- "Glass' delta"
names(x)[names(x) == "phi"] <- "Phi"
Expand Down Expand Up @@ -742,6 +746,25 @@ format_table <- function(x,



.format_symbols <- function(x, use_symbols) {
if (isTRUE(use_symbols) && .unicode_symbols()) {
colnames(x) <- gsub("Delta", "\u0394", colnames(x), ignore.case = TRUE)
colnames(x) <- gsub("Phi", "\u03D5", colnames(x), ignore.case = TRUE)
colnames(x) <- gsub("Eta", "\u03B7", colnames(x), ignore.case = TRUE)
colnames(x) <- gsub("Epsilon", "\u03b5", colnames(x), ignore.case = TRUE)
colnames(x) <- gsub("Omega", "\u03b5", colnames(x), ignore.case = TRUE)
colnames(x) <- gsub("R2", "R\u00b2", colnames(x), ignore.case = TRUE)
colnames(x) <- gsub("Chi2", "\u03C7\u00b2", colnames(x), ignore.case = TRUE)
colnames(x) <- gsub("Chi", "\u03C7", colnames(x), ignore.case = TRUE)
colnames(x) <- gsub("Sigma", "\u03C3", colnames(x), ignore.case = TRUE)
colnames(x) <- gsub("Rho", "\u03C1", colnames(x), ignore.case = TRUE)
colnames(x) <- gsub("Mu", "\u03BC", colnames(x), ignore.case = TRUE)
colnames(x) <- gsub("Theta", "\u03B8", colnames(x), ignore.case = TRUE)
}
x
}



# helper ---------------------

Expand Down

0 comments on commit 2cf02d5

Please sign in to comment.