Skip to content

Commit

Permalink
feat: #1979 modify check_type to supppress warnings for flag_all = TRUE
Browse files Browse the repository at this point in the history
  • Loading branch information
Zelos Zhu committed Jul 20, 2023
1 parent e6f9f80 commit d58f3da
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
26 changes: 19 additions & 7 deletions R/derive_var_extreme_flag.R
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,24 @@ derive_var_extreme_flag <- function(dataset,
)

# Create flag
data <- dataset %>%
derive_var_obs_number(
new_var = temp_obs_nr,
order = order,
by_vars = by_vars,
check_type = check_type
)
if (flag_all == TRUE) {
data <- dataset %>%
derive_var_obs_number(
new_var = temp_obs_nr,
order = order,
by_vars = by_vars,
check_type = "none"
)
}
else {
data <- dataset %>%
derive_var_obs_number(
new_var = temp_obs_nr,
order = order,
by_vars = by_vars,
check_type = check_type
)
}

if (mode == "first") {
data <- data %>%
Expand All @@ -262,6 +273,7 @@ derive_var_extreme_flag <- function(dataset,
}
}


# Remove temporary variable
data %>% select(-temp_obs_nr)
}
3 changes: 1 addition & 2 deletions tests/testthat/test-derive_var_extreme_flag.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ test_that("derive_var_extreme_flag Test 4: flag_all = TRUE when mode is first",
order = exprs(ADTM),
new_var = FIRSTFL,
mode = "first",
check_type = "none",
flag_all = TRUE
)

expect_true(all.equal(expected_output, actual_output))
})

## Test 5: flag_all = FALSE when mode is last ----
test_that("derive_var_extreme_flag Test 5: flag_all = FALSE when mode is last", {
expected_output <- test_flag_all %>%
Expand Down Expand Up @@ -157,7 +157,6 @@ test_that("derive_var_extreme_flag Test 6: flag_all = TRUE when mode is last", {
order = exprs(ADTM),
new_var = LASTFL,
mode = "last",
check_type = "none",
flag_all = TRUE
)

Expand Down

0 comments on commit d58f3da

Please sign in to comment.