Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check TIME and time when looking for mixed upper/lower case names in data #1099

Merged
merged 2 commits into from Jul 26, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/mrgindata.R
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
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