-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eeae265
commit 28a1a1a
Showing
3 changed files
with
48 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#' | ||
#' Check sex values in cause of death data based on CoDEdit rules | ||
#' | ||
#' @param sex_value An integer value or vector of values for age based on the | ||
#' CoDEdit rules. | ||
#' | ||
|
||
cod_check_sex <- function(sex_value) { | ||
## Create sex_check vector ---- | ||
sex_check <- vector(mode = "integer", length = length(sex_value)) | ||
|
||
## Check that sex_value is of the correct class ---- | ||
sex_check <- ifelse(!is.integer(sex_value), 1L, sex_check) | ||
|
||
## Check that sex_value is either 1L for males, 2L for females, and 9L for | ||
## unknown | ||
sex_check <- ifelse( | ||
any(!sex_value %in% c(1L, 2L, 9L)), sex_check + 2L, sex_check | ||
) | ||
|
||
|
||
## Check if sex_value is missing ---- | ||
sex_check <- ifelse(is.na(sex_value), sex_check + 4L, sex_check) | ||
|
||
## Create sex_check note vector ---- | ||
sex_check_note <- vector(mode = "character", length = length(sex_value)) | ||
|
||
sex_check_note[sex_check == 0] <- "No issues with sex values" | ||
sex_check_note[sex_check == 1] <- "Sex value is not an integer" | ||
sex_check_note[sex_check == 2] <- "Sex value is not any of the expected values" | ||
sex_check_note[sex_check == 3] <- "Sex value is not an integer; Sex value is not any of the expected values" | ||
sex_check_note[sex_check == 4] <- "Missing sex value" | ||
sex_check_note[sex_check == 5] <- "" | ||
|
||
} |
This file was deleted.
Oops, something went wrong.