check_subject_ids {cleanepi} | R Documentation |
Check whether the subject IDs comply with the expected format. When incorrect
IDs are found, the function sends a warning and the user can call the
correct_subject_ids
function to correct them.
Description
Check whether the subject IDs comply with the expected format. When incorrect
IDs are found, the function sends a warning and the user can call the
correct_subject_ids
function to correct them.
Usage
check_subject_ids(
data,
target_columns,
prefix = NULL,
suffix = NULL,
range = NULL,
nchar = NULL
)
Arguments
data |
The input |
target_columns |
A |
prefix |
A |
suffix |
A |
range |
A |
nchar |
An |
Value
The input dataset with a warning if incorrect subject ids were found
Examples
data <- readRDS(
system.file("extdata", "test_df.RDS", package = "cleanepi")
)
# make first and last subject IDs the same
data$study_id[10] <- data$study_id[1]
# set subject ID number 9 to NA
data$study_id[9] <- NA
# detect the incorrect subject ids i.e. IDs that do not have any or both of
# the followings:
# - starts with 'PS',
# - ends with 'P2',
# - has a number within 1 and 100,
# - contains 7 characters.
dat <- check_subject_ids(
data = data,
target_columns = "study_id",
prefix = "PS",
suffix = "P2",
range = c(1, 100),
nchar = 7
)
# display rows with invalid subject ids
print_report(dat, "incorrect_subject_id")
[Package cleanepi version 1.1.1 Index]