Skip to content
7 changes: 7 additions & 0 deletions R/format_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,13 @@ format_parameters.parameters_model <- function(model, ...) {
for (i in names(interactions)) {
# extract single coefficient names from interaction term
out <- unlist(strsplit(i, ":", fixed = TRUE))
# for on-the-fly conversion of factors, the names of the factors can
# can also contain "factor()" or "as.factor()" - we need to remove these
if (any(grepl("(as\\.factor|factor|as\\.character)", out))) {
out_clean <- gsub("(as\\.factor|factor|as\\.character)\\((.*)\\)(.*)", "\\2", out)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
out_clean <- gsub("(as\\.factor|factor|as\\.character)\\((.*)\\)(.*)", "\\2", out)
out_clean <- gsub(
"(as\\.factor|factor|as\\.character)\\((.*)\\)(.*)",
"\\2",
out
)

} else {
out_clean <- out
}
# combine labels
labs <- c(
labs,
Expand Down
6 changes: 5 additions & 1 deletion R/utils_model_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'
#' @keywords internal
#' @noRd
.add_model_parameters_attributes <- function(params,

Check warning on line 7 in R/utils_model_parameters.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/utils_model_parameters.R,line=7,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this expression from 43 to at most 40. Consider replacing high-complexity sections like loops and branches with helper functions.
model,
ci,
exponentiate = FALSE,
Expand Down Expand Up @@ -215,7 +215,11 @@
}

# add parameters with value and variable
attr(params, "pretty_labels") <- .format_value_labels(params, model)
if (isFALSE(dot.arguments$pretty_names)) {
attr(params, "pretty_labels") <- params$Parameter
} else if (is.null(attr(params, "pretty_labels", exact = TRUE))) {
attr(params, "pretty_labels") <- .format_value_labels(params, model)
}

row.names(params) <- NULL
params
Expand Down Expand Up @@ -254,7 +258,7 @@
#'
#' @keywords internal
#' @noRd
.find_coefficient_type <- function(info, exponentiate, model = NULL) {

Check warning on line 261 in R/utils_model_parameters.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/utils_model_parameters.R,line=261,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this expression from 57 to at most 40. Consider replacing high-complexity sections like loops and branches with helper functions.
# column name for coefficients
coef_col <- "Coefficient"
if (!is.null(model) && inherits(model, "emmGrid")) {
Expand Down
Loading