Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions .lintr
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
linters: linters_with_tags(
tags = NULL, # include all linters
linters: all_linters(
packages = c("lintr", "etdev"),
pipe_consistency_linter(pipe = "%>%"),
object_name_linter = NULL,
undesirable_function_linter = NULL,
implicit_integer_linter = NULL,
extraction_operator_linter = NULL,
todo_comment_linter = NULL,
function_argument_linter = NULL
library_call_linter = NULL,
undesirable_function_linter(
modify_defaults(
default_undesirable_functions,
citEntry = "use the more modern bibentry() function",
library = NULL # too many false positive in too many files
)
),
function_argument_linter = NULL,
object_overwrite_linter = NULL,
return_linter = NULL,
# Use minimum R declared in DESCRIPTION or fall back to current R version.
# Install etdev package from https://github.com/epiverse-trace/etdev
backport_linter(if (length(x <- etdev::extract_min_r_version())) x else getRversion())
)
exclusions: list(
"tests/testthat.R" = list(unused_import_linter = Inf)
"tests/testthat.R" = list(
unused_import_linter = Inf
),
"tests" = list(
undesirable_function_linter = Inf
),
"data-raw" = list(
missing_package_linter = Inf,
namespace_linter = Inf
),
# RcppExports.R is auto-generated and will not pass many linters. In
# particular, it can create very long lines.
"R/RcppExports.R",
# R/stanmodels.R is auto-generated and will not pass many linters. In
# particular, it uses `sapply()`.
"R/stanmodels.R"
)
2 changes: 1 addition & 1 deletion R/coh_data_wrangling.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ truncate_from_start_cohort <- function(data_set,
" the mininimum immunization date. \n",
n0 - nf, " registers were removed with outcomes before the start date.\n"
)
warning(msg)
warning(msg, call. = FALSE)

return(data_set)
}
2 changes: 1 addition & 1 deletion R/coh_eff_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ cox_model <- function(data_set,
# Cox model time to event, outcome ~ vaccine status
# Regression
model <- survival::coxph(
survival::Surv( # nolint
survival::Surv(
data_set[[time_to_event_col]], data_set[[outcome_status_col]]
) ~ data_set[[vacc_status_col]]
)
Expand Down
11 changes: 5 additions & 6 deletions R/coh_immunization.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,12 @@ get_immunization_date <- function(data_set,
#(i.e. the max delta). If take_firt = FALSE it returns the
#closest date to the event (i.e. the min delta).
if (all(is.na(x))) {
NA_real_
return(NA_real_)
}
if (take_first) {
max(x, na.rm = TRUE)
} else {
if (take_first) {
max(x, na.rm = TRUE)
} else {
min(x, na.rm = TRUE)
}
min(x, na.rm = TRUE)
}
}
)
Expand Down
7 changes: 4 additions & 3 deletions R/coh_match_iterate.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ rematch_ <- function(all,
start_cohort = start_cohort,
end_cohort = end_cohort
)
warning("Iteration ", im, " for ", rematch_status)
warning(" - New: ", nrow(adjusted_i_s), "\n")
warning("Iteration ", im, " for ", rematch_status, call. = FALSE)
warning(" - New: ", nrow(adjusted_i_s), "\n", call. = FALSE)
},
error = function(e) {
# MatchIt returns error if there are no enough individuals
# from both groups to match
warning(
"Error at iteration ", im, " for ", rematch_status, ": ",
e$message, "- skipping to next \n"
e$message, "- skipping to next \n",
call. = FALSE
)
}
)
Expand Down
2 changes: 1 addition & 1 deletion R/coh_match_static.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static_match <- function(data_set,
adjusted_f <- adjusted_f[, -which(names(adjusted_f) == "match_id")]

warning(
warning_1, warning_2, warning_3, warning_4
warning_1, warning_2, warning_3, warning_4, call. = FALSE
)

# Match object
Expand Down
12 changes: 6 additions & 6 deletions R/coh_match_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ match_pair_info <- function(data_set,
function(x) {
if (all(is.na(x))) {
return(NA)
} else {
if (criteria == "min") {
return(as.character(min(x, na.rm = TRUE)))
} else if (criteria == "max") {
return(as.character(max(x, na.rm = TRUE)))
}
}
if (criteria == "min") {
return(as.character(min(x, na.rm = TRUE)))
}
if (criteria == "max") {
return(as.character(max(x, na.rm = TRUE)))
}
}
)
Expand Down
6 changes: 4 additions & 2 deletions R/handler_validations.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ check_vaccineff_inputs <- function(data_set,
sprintf(
"`end_cohort` has a date with year > %s, please check the date!",
as.character(max_year)
)
),
call. = FALSE
)
}

Expand All @@ -119,7 +120,8 @@ check_vaccineff_inputs <- function(data_set,
# Check if both 'exact' and 'nearest' are NULL or missing
if (is.null(nearest) && is.null(exact)) {
stop(
"`exact` and `nearest` cannot be NULL. At least one must be provided"
"`exact` and `nearest` cannot be NULL. At least one must be provided",
call. = FALSE
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/utils_get_age_group.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ get_age_group <- function(data_set, col_age, max_val, min_val = 0, step) {
war_msg <- "(max_val - min_val) must be an integer multiple of step.
The last interval will be truncated to "
war_msg <- paste0(war_msg, lim_labels[length(lim_labels)])
warning(war_msg)
warning(war_msg, call. = FALSE)
}

# cut the age data and apply labels
Expand Down
11 changes: 0 additions & 11 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,19 @@ VE
WIP
Zulma
anonymised
codecov
confounders
cumincidence
de
disaggregated
eq
frac
funder
ggplot
gh
github
https
img
invokeRestart
io
lifecycle
muffleWarning
packagename
repo
rmarkdown
surv
svg
unadjusted
unvaccinated
www
yaml
Érika
4 changes: 2 additions & 2 deletions tests/testthat/test-coh_data_wrangling.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test_that("`set_status`: Correctness", {
cohortdata[, c("death_date", "vaccine_date_1")],
MARGIN = 1,
FUN = function(x) {
all(!is.na(x)) # nolint
all(!is.na(x))
}
)
expect_identical(
Expand All @@ -88,7 +88,7 @@ test_that("`set_status`: Correctness", {
cohortdata[, c("death_date", "vaccine_date_1")],
MARGIN = 1,
FUN = function(x) {
any(!is.na(x)) # nolint
any(!is.na(x))
}
)
expect_identical(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-coh_match.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test_that("`match_cohort`: basic expectations", {
})

# Snapshot for summary
test_that("`match_cohort`: summary snapshot", { # nolint
test_that("`match_cohort`: summary snapshot", {
for (column in c("balance_all", "balance_match", "summary")) {
expect_snapshot_value(matching[column], style = "json2", tolerance = 1e-1)
}
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-handler_warnings.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Example function that generates warnings
example_function <- function() {
warning("This is warning 1")
warning("This is warning 2")
warning("This is warning 1", call. = FALSE)
warning("This is warning 2", call. = FALSE)
return("Function completed")
}

Expand Down
1 change: 1 addition & 0 deletions vaccineff.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 88426aa9-8cf3-4db4-aaf2-686ba4a249cd

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down