Skip to content

Commit 49b885f

Browse files
committed
test, lintr
1 parent bb17417 commit 49b885f

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

R/check_heterogeneity_bias.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ check_heterogeneity_bias <- function(x, select = NULL, group = NULL) {
3131
if (insight::is_model(x)) {
3232
group <- insight::find_random(x, split_nested = TRUE, flatten = TRUE)
3333
if (is.null(group)) {
34-
insight::format_error("Model is no mixed model. Please provide a mixed model, or a data frame and arguments `select` and `group`.")
34+
insight::format_error("Model is no mixed model. Please provide a mixed model, or a data frame and arguments `select` and `group`.") # nolint
3535
}
36-
data <- insight::get_data(x, source = "mf", verbose = FALSE)
36+
my_data <- insight::get_data(x, source = "mf", verbose = FALSE)
3737
select <- insight::find_predictors(x, effects = "fixed", component = "conditional", flatten = TRUE)
3838
} else {
3939
if (inherits(select, "formula")) {
@@ -42,15 +42,15 @@ check_heterogeneity_bias <- function(x, select = NULL, group = NULL) {
4242
if (inherits(group, "formula")) {
4343
group <- all.vars(group)
4444
}
45-
data <- x
45+
my_data <- x
4646
}
4747

48-
unique_groups <- .n_unique(data[[group]])
48+
unique_groups <- .n_unique(my_data[[group]])
4949
combinations <- expand.grid(select, group)
5050

5151
result <- Map(function(predictor, id) {
5252
# demean predictor
53-
d <- datawizard::demean(data, select = predictor, group = id, verbose = FALSE)
53+
d <- datawizard::demean(my_data, select = predictor, group = id, verbose = FALSE)
5454

5555
# get new names
5656
within_name <- paste0(predictor, "_within")

tests/testthat/test-check_outliers.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,17 @@ test_that("mcd which", {
8787
# (not clear why method mcd needs a seed)
8888
set.seed(42)
8989
expect_identical(
90-
tail(which(check_outliers(mtcars[1:4], method = "mcd", threshold = 45))),
90+
tail(which(check_outliers(mtcars[1:4], method = "mcd", threshold = 45, verbose = FALSE))),
9191
31L
9292
)
93-
out <- check_outliers(mtcars, method = "mcd")
93+
expect_warning(
94+
{
95+
out <- check_outliers(mtcars, method = "mcd")
96+
},
97+
regex = "The sample size is too small"
98+
)
9499
expect_identical(sum(out), 8L)
95-
out <- check_outliers(mtcars, method = "mcd", percentage_central = 0.5)
100+
out <- check_outliers(mtcars, method = "mcd", percentage_central = 0.5, verbose = FALSE)
96101
expect_identical(sum(out), 15L)
97102
})
98103

@@ -228,7 +233,8 @@ test_that("multiple methods with ID", {
228233
mahalanobis = 20, mahalanobis_robust = 25, mcd = 25,
229234
optics = 14, lof = 0.005
230235
),
231-
ID = "car"
236+
ID = "car",
237+
verbose = FALSE
232238
))
233239
expect_identical(
234240
x$outlier_var$zscore$mpg$car,

0 commit comments

Comments
 (0)