Skip to content

Commit

Permalink
Added input validation to prepare_serodata()
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmbaazam committed Aug 3, 2023
1 parent 4b22dac commit 295eebe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ LazyData: true
RoxygenNote: 7.2.3
Depends:
R (>= 3.5.0)
Imports:
Imports:
checkmate,
methods,
Rcpp (>= 0.12.0),
RcppParallel (>= 5.0.1),
Expand Down
10 changes: 10 additions & 0 deletions R/seroprevalence_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@
prepare_serodata <- function(serodata = serodata,
alpha = 0.05,
add_age_mean_f = TRUE) {
checkmate::assert_numeric(alpha, lower = 0, upper = 1)
checkmate::assert_logical(add_age_mean_f)
#Check that serodata has the right columns
stopifnot("serodata must contain the right columns" =
setequal(names(serodata),
c("survey", "total", "counts", "age_min","age_max",
"tsur", "country","test", "antibody"
)
)
)
if(add_age_mean_f){
serodata <- serodata %>%
dplyr::mutate(age_mean_f = floor((age_min + age_max) / 2), sample_size = sum(total)) %>%
Expand Down

0 comments on commit 295eebe

Please sign in to comment.