Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Dec 18, 2024
1 parent d085d8c commit 98695f2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/data_arrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ data_arrange.default <- function(data, select = NULL, safe = TRUE) {
select <- gsub("^-", "", select)

# check for variables that are not in data
dont_exist <- select[which(!select %in% names(data))]
dont_exist <- setdiff(select, colnames(data))

if (length(dont_exist) > 0) {
if (safe) {
Expand Down
2 changes: 2 additions & 0 deletions R/rescale_weights.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ rescale_weights <- function(data,
probability_weights = NULL,
nest = FALSE,
method = "carle") {
method <- insight::validate_argument(method, c("carle", "kish"))

if (inherits(by, "formula")) {
by <- all.vars(by)
}
Expand Down
2 changes: 1 addition & 1 deletion man/rescale_weights.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/testthat/test-rescale_weights.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ test_that("rescale_weights errors and warnings", {
),
regex = "is not used"
)
expect_warning(
rescale_weights(
data = head(nhanes_sample, n = 30),
probability_weights = "WTINT2YR",
method = "dish"
),
regex = "Invalid option for argument"
)

nhanes_sample$rescaled_weights_a <- 1
expect_warning(
Expand Down

0 comments on commit 98695f2

Please sign in to comment.