Skip to content

Commit

Permalink
lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Sep 11, 2023
1 parent 8ef01f5 commit dd574ba
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 78 deletions.
12 changes: 6 additions & 6 deletions R/extract_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -945,12 +945,12 @@
}

type <- switch(standardize,
"all" = ,
"std.all" = "std.all",
"latent" = ,
"std.lv" = "std.lv",
"no_exogenous" = ,
"std.nox" = "std.nox",
all = ,
std.all = "std.all",
latent = ,
std.lv = "std.lv",
no_exogenous = ,
std.nox = "std.nox",
"std.all"
)

Expand Down
8 changes: 4 additions & 4 deletions R/extract_parameters_anova.R
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@
}
eigs <- Re(eigen(qr.coef(qr_value, model$SSP[[i]]), symmetric = FALSE)$values)
test <- switch(model$test,
"Pillai" = .pillai_test(eigs, model$df[i], model$error.df),
"Wilks" = .wilks_test(eigs, model$df[i], model$error.df),
"Hotelling-Lawley" = .hl_test(eigs, model$df[i], model$error.df),
"Roy" = .roy_test(eigs, model$df[i], model$error.df)
Pillai = .pillai_test(eigs, model$df[i], model$error.df),
Wilks = .wilks_test(eigs, model$df[i], model$error.df),
`Hotelling-Lawley` = .hl_test(eigs, model$df[i], model$error.df),
Roy = .roy_test(eigs, model$df[i], model$error.df)
)
data.frame(
Parameter = model$terms[i],
Expand Down
6 changes: 3 additions & 3 deletions R/extract_random_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@

# filter component
out <- switch(component,
"zi" = ,
"zero_inflated" = out[out$Component == "zi", ],
"conditional" = out[out$Component == "cond", ],
zi = ,
zero_inflated = out[out$Component == "zi", ],
conditional = out[out$Component == "cond", ],
out
)

Expand Down
18 changes: 9 additions & 9 deletions R/format_df_adjust.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ format_df_adjust <- function(method,
method <- tolower(method)

out <- switch(method,
"kr" = ,
"kenward-rogers" = ,
"kenward-roger" = ,
"kenward" = "Kenward-Roger",
"ml1" = "m-l-1",
"betwithin" = ,
"bw" = "Between-within",
"fit" = "Residual",
"boot" = "Bootstrapped",
kr = ,
`kenward-rogers` = ,
`kenward-roger` = ,
kenward = "Kenward-Roger",
ml1 = "m-l-1",
betwithin = ,
bw = "Between-within",
fit = "Residual",
boot = "Bootstrapped",
insight::format_capitalize(method)
)

Expand Down
38 changes: 19 additions & 19 deletions R/format_order.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ format_order <- function(order, textual = TRUE, ...) {
order <- insight::format_number(order)
parts <- unlist(strsplit(order, " ", fixed = TRUE))
parts[length(parts)] <- switch(utils::tail(parts, 1),
"one" = "first",
"two" = "second",
"three" = "third",
"four" = "fourth",
"five" = "fifth",
"six" = "sixth",
"seven" = "seventh",
"eight" = "eigth",
"nine" = "ninth"
one = "first",
two = "second",
three = "third",
four = "fourth",
five = "fifth",
six = "sixth",
seven = "seventh",
eight = "eigth",
nine = "ninth"
)
out <- paste(parts, collapse = " ")
} else {
Expand All @@ -39,16 +39,16 @@ format_order <- function(order, textual = TRUE, ...) {
out <- paste0(
number,
switch(last,
"1" = "st",
"2" = "nd",
"3" = "rd",
"4" = "th",
"5" = "th",
"6" = "th",
"7" = "th",
"8" = "th",
"9" = "th",
"0" = "th"
`1` = "st",
`2` = "nd",
`3` = "rd",
`4` = "th",
`5` = "th",
`6` = "th",
`7` = "th",
`8` = "th",
`9` = "th",
`0` = "th"
)
)
}
Expand Down
20 changes: 10 additions & 10 deletions R/format_p_adjust.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ format_p_adjust <- function(method) {
method <- tolower(method)

switch(method,
"holm" = "Holm (1979)",
"hochberg" = "Hochberg (1988)",
"hommel" = "Hommel (1988)",
"bonferroni" = "Bonferroni",
"fdr" = "Benjamini & Hochberg (1995)",
"bh" = "Benjamini & Hochberg (1995)",
"by" = "Benjamini & Yekutieli (2001)",
"tukey" = "Tukey",
"scheffe" = "Scheffe",
"sidak" = "Sidak",
holm = "Holm (1979)",
hochberg = "Hochberg (1988)",
hommel = "Hommel (1988)",
bonferroni = "Bonferroni",
fdr = "Benjamini & Hochberg (1995)",
bh = "Benjamini & Hochberg (1995)",
by = "Benjamini & Yekutieli (2001)",
tukey = "Tukey",
scheffe = "Scheffe",
sidak = "Sidak",
method
)
}
Expand Down
6 changes: 3 additions & 3 deletions R/format_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ format_parameters.parameters_model <- function(model, ...) {
#' @keywords internal
.format_ordered <- function(degree, brackets = c("[", "]")) {
switch(degree,
".L" = paste0(brackets[1], "linear", brackets[2]),
".Q" = paste0(brackets[1], "quadratic", brackets[2]),
".C" = paste0(brackets[1], "cubic", brackets[2]),
`.L` = paste0(brackets[1], "linear", brackets[2]),
`.Q` = paste0(brackets[1], "quadratic", brackets[2]),
`.C` = paste0(brackets[1], "cubic", brackets[2]),
paste0(
brackets[1],
parameters::format_order(as.numeric(gsub("^", "", degree, fixed = TRUE)), textual = FALSE),
Expand Down
12 changes: 6 additions & 6 deletions R/methods_aov.R
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,12 @@ model_parameters.maov <- model_parameters.aov
return(type)
}
switch(type,
"1" = ,
"I" = 1,
"2" = ,
"II" = 2,
"3" = ,
"III" = 3,
`1` = ,
`I` = 1,
`2` = ,
`II` = 2,
`3` = ,
`III` = 3,
1
)
}
Expand Down
4 changes: 2 additions & 2 deletions R/methods_fixest.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ degrees_of_freedom.fixest <- function(model, method = "wald", ...) {
}

method <- switch(method,
"wald" = "t",
"residual" = "resid"
wald = "t",
residual = "resid"
)
fixest::degrees_freedom(model, type = method)
}
Expand Down
2 changes: 1 addition & 1 deletion R/methods_lme4.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ model_parameters.merMod <- function(model,
ci_method <- "quantile"
} else {
ci_method <- switch(insight::find_statistic(model),
"t-statistic" = "residual",
`t-statistic` = "residual",
"wald"
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/methods_metaplus.R
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ ci.meta_bma <- ci.meta_random

.metabma_ci_columns <- function(ci_method, ci) {
switch(toupper(ci_method),
"HDI" = sprintf(c("hpd%i_lower", "hpd%i_upper"), 100 * ci),
HDI = sprintf(c("hpd%i_lower", "hpd%i_upper"), 100 * ci),
c(sprintf("%g%%", (100 * (1 - ci)) / 2), sprintf("%g%%", 100 - (100 * (1 - ci)) / 2))
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/methods_mmrm.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ model_parameters.mmrm <- function(model,
verbose = TRUE,
...) {
ci_method <- switch(model$method,
"Satterthwaite" = "satterthwaite",
Satterthwaite = "satterthwaite",
"kenward"
)

Expand Down
12 changes: 6 additions & 6 deletions R/methods_quantreg.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ standard_error.rqss <- function(model,
)

switch(component,
"all" = rbind(out_cond, out_smooth),
"conditional" = out_cond,
"smooth_terms" = out_smooth
all = rbind(out_cond, out_smooth),
conditional = out_cond,
smooth_terms = out_smooth
)
}

Expand Down Expand Up @@ -269,9 +269,9 @@ p_value.rqss <- function(model,
)

switch(component,
"all" = rbind(out_cond, out_smooth),
"conditional" = out_cond,
"smooth_terms" = out_smooth
all = rbind(out_cond, out_smooth),
conditional = out_cond,
smooth_terms = out_smooth
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/p_calibrate.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ format.p_calibrate <- function(x, ...) {
print.p_calibrate <- function(x, ...) {
formatted <- format(x, ...)
footer <- switch(attributes(x)$type,
"frequentist" = "Calibrated p-values indicate the posterior probability of H0.\n",
frequentist = "Calibrated p-values indicate the posterior probability of H0.\n",
"Calibrated p-values indicate the Bayes Factor (evidence) in favor of H0 over H1.\n"
)
cat(insight::export_table(formatted, footer = c(footer, "blue"), ...))
Expand Down
4 changes: 2 additions & 2 deletions R/sort_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ sort_parameters.default <- function(x, sort = "none", column = "Coefficient", ..

# new row indices to use for sorting
new_row_order <- switch(sort,
"ascending" = order(x[[column]], decreasing = FALSE),
"descending" = order(x[[column]], decreasing = TRUE)
ascending = order(x[[column]], decreasing = FALSE),
descending = order(x[[column]], decreasing = TRUE)
)

x[new_row_order, ]
Expand Down
6 changes: 3 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
#' @keywords internal
.filter_component <- function(dat, component) {
switch(component,
"conditional" = dat[dat$Component == "conditional", ],
"zi" = ,
"zero_inflated" = dat[dat$Component == "zero_inflated", ],
conditional = dat[dat$Component == "conditional", ],
zi = ,
zero_inflated = dat[dat$Component == "zero_inflated", ],
dat
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/utils_model_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
emmean = "Marginal Means",
rate = "Estimated Counts",
ratio = "Ratio",
Coefficient
"Coefficient"
)
}
} else if (!is.null(info) && !info$family == "unknown") {
Expand Down

0 comments on commit dd574ba

Please sign in to comment.