Skip to content

Commit

Permalink
strict more testly around detected names
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmbarrett committed Feb 4, 2025
1 parent e074e54 commit d56c2c2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/ipw.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ ipw <- function(ps_mod, outcome_mod, .df = NULL, estimand = NULL, ps_link = NULL
exposure <- fmla_extract_left_vctr(ps_mod)
outcome <- fmla_extract_left_vctr(outcome_mod)
} else {
stopifnot(rlang::is_scalar_character(exposure_name) && rlang::is_scalar_character(exposure_name))
stopifnot(all(c(exposure_name, outcome_name) %in% names(.df)))
exposure <- .df[[exposure_name]]
outcome <- .df[[outcome_name]]
}
Expand Down Expand Up @@ -576,6 +578,7 @@ check_estimand <- function(wts, estimand) {
}

check_exposure <- function(.df, .exposure_name) {
stopifnot(rlang::is_scalar_character(.exposure_name))
if (!(.exposure_name %in% names(.df))) {
stop(
.exposure_name,
Expand Down

0 comments on commit d56c2c2

Please sign in to comment.