Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Oct 27, 2024
1 parent 74fb5cf commit 24e0143
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions R/clean_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,27 +171,8 @@ clean_names.character <- function(x, include_names = FALSE, ...) {
} else if (pattern[j] == "scale(poly") {
i <- trim_ws(unique(sub("^scale\\(poly\\(((\\w|\\.)*).*", "\\1", i)))
} else if (pattern[j] %in% c("mmc", "mm")) {
# # detect mm-pattern
# p <- paste0("^", pattern[j], "\\((.*)\\).*")
# # extract terms from mm() / mmc() functions
# g <- trim_ws(sub(p, "\\1", i))
# # split terms, but not if comma inside parentheses
# g <- trim_ws(unlist(strsplit(g, ",(?![^()]*\\))", perl = TRUE), use.names = FALSE))
# # we might have additional arguments, like scale or weights. handle these here
# g <- g[!startsWith(g, "scale")]
# # clean weights
# gweights <- g[startsWith(g, "weights")]
# if (length(gweights)) {
# g <- g[!startsWith(g, "weights")]
# # this regular pattern finds "weights=" or "weights =", possibly followed
# # by "cbind()", e.g. "weights = cbind(w, w)". We extract the variable names,
# # create a formula, so "all.vars()" will only extract variable names if
# # we really have "cbind()" in the weights argument
# g <- c(g, .safe(all.vars(as.formula(paste0("~", trim_ws(gsub("weights\\s?=(.*)", "\\1", "weights = cbind(w, w)"))))))) # nolint
# }
# multimembership <- as.vector(trim_ws(g))
if (grepl(paste0("^", pattern[j], "\\((.*)\\).*"), i)) {
multimembership <- all.vars(stats::as.formula(paste("~", i)))
i <- all.vars(stats::as.formula(paste("~", i)))
}
} else if (pattern[j] == "s" && startsWith(i, "s(")) {
i <- gsub("^s\\(", "", i)
Expand All @@ -218,12 +199,8 @@ clean_names.character <- function(x, include_names = FALSE, ...) {
if (grepl("|", i, fixed = TRUE)) {
i <- sub("^(.*)\\|(.*)", "\\2", i)
}
# either return regular term, or mm term for brms
if (is.null(multimembership)) {
trim_ws(i)
} else {
multimembership
}

trim_ws(i)
}), use.names = FALSE)

# remove for random intercept only models
Expand Down

0 comments on commit 24e0143

Please sign in to comment.