Skip to content

Commit

Permalink
lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Dec 1, 2023
1 parent f444f76 commit 905cde5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 39 deletions.
50 changes: 24 additions & 26 deletions R/plot.check_collinearity.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ plot.see_check_collinearity <- function(x,
xlim <- nrow(x)
if (ylim < 10) ylim <- 10

if (!is.null(ci_data)) {
x <- cbind(x, ci_data)
} else {
if (is.null(ci_data)) {
x$VIF_CI_low <- NA_real_
x$VIF_CI_high <- NA_real_
} else {
x <- cbind(x, ci_data)
}

# make sure legend is properly sorted
Expand Down Expand Up @@ -119,31 +119,29 @@ plot.see_check_collinearity <- function(x,
color = NA,
alpha = 0.15
) +
{
if (!is.null(ci_data)) {
list(
ggplot2::geom_linerange(
linewidth = size_line,
na.rm = TRUE
if (!is.null(ci_data)) {

Check warning on line 122 in R/plot.check_collinearity.R

View workflow job for this annotation

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

file=R/plot.check_collinearity.R,line=122,col=28,[brace_linter] Opening curly braces should never go on their own line and should always be followed by a new line.

Check warning on line 122 in R/plot.check_collinearity.R

View workflow job for this annotation

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

file=R/plot.check_collinearity.R,line=122,col=28,[unnecessary_nesting_linter] Reduce the nesting of this statement by removing the braces {}.

Check warning on line 122 in R/plot.check_collinearity.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/plot.check_collinearity.R,line=122,col=28,[brace_linter] Opening curly braces should never go on their own line and should always be followed by a new line.

Check warning on line 122 in R/plot.check_collinearity.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/plot.check_collinearity.R,line=122,col=28,[unnecessary_nesting_linter] Reduce the nesting of this statement by removing the braces {}.
list(
ggplot2::geom_linerange(
linewidth = size_line,
na.rm = TRUE
),
ggplot2::geom_segment(
data = x[x$VIF_CI_high > ylim * 1.15, ],
mapping = aes(
x = .data$x,
xend = .data$x,
y = .data$y,
yend = .data$VIF_CI_high
),
lineend = "round",
linejoin = "round",
arrow = ggplot2::arrow(
ends = "last", type = "closed",
angle = 20, length = ggplot2::unit(0.03, "native")
),
ggplot2::geom_segment(
data = x[x$VIF_CI_high > ylim * 1.15, ],
mapping = aes(
x = .data$x,
xend = .data$x,
y = .data$y,
yend = .data$VIF_CI_high
),
lineend = "round",
linejoin = "round",
arrow = ggplot2::arrow(
ends = "last", type = "closed",
angle = 20, length = ggplot2::unit(0.03, "native")
),
show.legend = FALSE
)
show.legend = FALSE
)
}
)
} +

Check warning on line 145 in R/plot.check_collinearity.R

View workflow job for this annotation

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

file=R/plot.check_collinearity.R,line=145,col=5,[brace_linter] Closing curly-braces should always be on their own line, unless they are followed by an else.

Check warning on line 145 in R/plot.check_collinearity.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/plot.check_collinearity.R,line=145,col=5,[brace_linter] Closing curly-braces should always be on their own line, unless they are followed by an else.
geom_point2(

Check warning on line 146 in R/plot.check_collinearity.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/plot.check_collinearity.R,line=146,col=4,[indentation_linter] Indentation should be 6 spaces but is 4 spaces.
size = size_point,
Expand Down
24 changes: 11 additions & 13 deletions R/plot.check_heteroscedasticity.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,19 @@ plot.see_check_heteroscedasticity <- function(x, data = NULL, ...) {

faminfo <- insight::model_info(model)
r <- tryCatch(
{
if (inherits(model, "merMod")) {
stats::residuals(model, scaled = TRUE)
} else if (inherits(model, c("glmmTMB", "MixMod"))) {
sigma <- if (faminfo$is_mixed) {
sqrt(insight::get_variance_residual(model))
} else {
.sigma_glmmTMB_nonmixed(model, faminfo)
}
stats::residuals(model) / sigma
} else if (inherits(model, "glm")) {
stats::rstandard(model, type = "pearson")
if (inherits(model, "merMod")) {
stats::residuals(model, scaled = TRUE)
} else if (inherits(model, c("glmmTMB", "MixMod"))) {
sig <- if (faminfo$is_mixed) {
sqrt(insight::get_variance_residual(model))
} else {
stats::rstandard(model)
.sigma_glmmTMB_nonmixed(model, faminfo)
}
stats::residuals(model) / sig
} else if (inherits(model, "glm")) {
stats::rstandard(model, type = "pearson")
} else {
stats::rstandard(model)
},
error = function(e) {
NULL
Expand Down

0 comments on commit 905cde5

Please sign in to comment.