# detect the incorrect subject ids
dat <- check_subject_ids(
data = readRDS(
system.file("extdata", "test_df.RDS", package = "cleanepi")
),
target_columns = "study_id",
prefix = "PS",
suffix = "P2",
range = c(1, 100),
nchar = 7
)
# generate the correction table
correction_table <- data.frame(
from = c("P0005P2", "PB500P2", "PS004P2-1"),
to = c("PB005P2", "PB050P2", "PS004P2")
)
# perform the correction
dat <- correct_subject_ids(
data = dat,
target_columns = "study_id",
correction_table = correction_table
)
Run the code above in your browser using DataLab