Skip to content

Commit

Permalink
check TIME and time when looking for mixed upper/lower case names in …
Browse files Browse the repository at this point in the history
…data
  • Loading branch information
kylebaron committed Jul 25, 2023
1 parent c13335f commit 54f67c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/mrgindata.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ valid_data_set <- function(x, m = NULL, verbose = FALSE, quiet = FALSE) {
dimnames=list(NULL, "..zeros..")))

# Look for both upper and lower case column names
uc <- any(dimnames(dm)[[2]] %in% GLOBALS[["CARRY_TRAN_UC"]])
lc <- any(dimnames(dm)[[2]] %in% GLOBALS[["CARRY_TRAN_LC"]])
uc <- any(dimnames(dm)[[2]] %in% GLOBALS[["TRAN_UPPER"]])
lc <- any(dimnames(dm)[[2]] %in% GLOBALS[["TRAN_LOWER"]])

if(uc & lc) {
warning("Both lower- & upper-case names found in the data set.\n",
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-data_set.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ test_that("Warning is generated when mixed upper/lower names", {
expect_warning(mrgsim(data_set(mod,mix)))
})

test_that("Include TIME and time when checking for mixed upper/lower case", {
expect_warning(
mrgsim(house(), data = data.frame(ID = 1, TIME = 0, amt = 0, cmt = 1)),
"Both lower- & upper-case",
fixed = TRUE
)
expect_warning(
mrgsim(house(), data = data.frame(ID = 1, time = 0, AMT = 0, cmt = 1)),
"Both lower- & upper-case",
fixed = TRUE
)
})

test_that("Filter out ID", {
out <- mod %>% data_set(up, ID > 4) %>% mrgsim
expect_true(all(out$ID > 4))
Expand Down

0 comments on commit 54f67c8

Please sign in to comment.