Given a secuTrialdata
object, and subsetting parameters,
this function filters the data object to include only the desired study participants.
Subsetting is possible based on participants and based on centres. In order to subset
based on participants, participant IDs (mnpaid) musst be present in the export.
In order to subset based on centres, centre information must be included in the export.
subset_secuTrial(dat, participant = NULL, centre = NULL, exclude = FALSE)
secuTrialdata
object containing participant IDs and centre information
character vector with a selection of participant IDs (mnpaid) used for subsetting
character vector with a selection of centre names (mnpctrname) used for subsetting
boolean which if true excludes participants and centres from dat
secuTrialdata
object containing only those participants that meet the selection criteria.
Subsetting based on participants only, centers only, or based on both is possible. The value of parameter exclude determines whether the output will include participants that meet selection criteria (when exclude = FALSE), or exclude them (when exclude = TRUE). When selecting based on both participants and centres, exclude = FALSE will include the intersection of participants meeting the selection criteria. If exclude = TRUE, a complement of union of participant and centre sets is returned.
path <- system.file("extdata", "sT_exports", "exp_opt",
"s_export_CSV-xls_CTU05_all_info.zip",
package = "secuTrialR")
sT <- read_secuTrial(path)
#> Read export successfully.
#> The following export options deviate from the suggested specifications:
#> Data from hidden fields is part of the export.
participants <- c("RPACK-INS-011", "RPACK-INS-014", "RPACK-INS-015")
centres <- c("Inselspital Bern (RPACK)", "Universitätsspital Basel (RPACK)")
# show all participants
get_participants(sT)
#> mnppid mnpaid mnpctrid mnpctrname
#> 1 1204 RPACK-CBE-001 462 Charité Berlin (RPACK)
#> 2 1205 RPACK-CBE-002 462 Charité Berlin (RPACK)
#> 3 1206 RPACK-CBE-003 462 Charité Berlin (RPACK)
#> 4 1207 RPACK-CBE-004 462 Charité Berlin (RPACK)
#> 5 1208 RPACK-CBE-005 462 Charité Berlin (RPACK)
#> 6 1209 RPACK-INS-011 461 Inselspital Bern (RPACK)
#> 7 1210 RPACK-INS-012 461 Inselspital Bern (RPACK)
#> 8 1211 RPACK-INS-013 461 Inselspital Bern (RPACK)
#> 9 1212 RPACK-INS-014 461 Inselspital Bern (RPACK)
#> 10 1213 RPACK-INS-015 461 Inselspital Bern (RPACK)
#> 11 1214 RPACK-USB-123 441 Universitätsspital Basel (RPACK)
# subset sT_export
sT_subset1 <- subset_secuTrial(dat = sT, participant = participants)
#> If you changed any labels in the secuTrialdata object manually these will be reset to their original state.
get_participants(sT_subset1)
#> mnppid mnpaid mnpctrid mnpctrname
#> 1 1209 RPACK-INS-011 461 Inselspital Bern (RPACK)
#> 2 1212 RPACK-INS-014 461 Inselspital Bern (RPACK)
#> 3 1213 RPACK-INS-015 461 Inselspital Bern (RPACK)
sT_subset2 <- subset_secuTrial(dat = sT, participant = participants, exclude = TRUE)
#> If you changed any labels in the secuTrialdata object manually these will be reset to their original state.
get_participants(sT_subset2)
#> mnppid mnpaid mnpctrid mnpctrname
#> 1 1204 RPACK-CBE-001 462 Charité Berlin (RPACK)
#> 2 1205 RPACK-CBE-002 462 Charité Berlin (RPACK)
#> 3 1206 RPACK-CBE-003 462 Charité Berlin (RPACK)
#> 4 1207 RPACK-CBE-004 462 Charité Berlin (RPACK)
#> 5 1208 RPACK-CBE-005 462 Charité Berlin (RPACK)
#> 6 1210 RPACK-INS-012 461 Inselspital Bern (RPACK)
#> 7 1211 RPACK-INS-013 461 Inselspital Bern (RPACK)
#> 8 1214 RPACK-USB-123 441 Universitätsspital Basel (RPACK)
sT_subset3 <- subset_secuTrial(dat = sT, centre = centres, exclude = TRUE)
#> If you changed any labels in the secuTrialdata object manually these will be reset to their original state.
get_participants(sT_subset3)
#> mnppid mnpaid mnpctrid mnpctrname
#> 1 1204 RPACK-CBE-001 462 Charité Berlin (RPACK)
#> 2 1205 RPACK-CBE-002 462 Charité Berlin (RPACK)
#> 3 1206 RPACK-CBE-003 462 Charité Berlin (RPACK)
#> 4 1207 RPACK-CBE-004 462 Charité Berlin (RPACK)
#> 5 1208 RPACK-CBE-005 462 Charité Berlin (RPACK)
sT_subset4 <- subset_secuTrial(dat = sT, participant = participants,
centre = centres, exclude = FALSE)
#> If you changed any labels in the secuTrialdata object manually these will be reset to their original state.
get_participants(sT_subset4)
#> mnppid mnpaid mnpctrid mnpctrname
#> 1 1209 RPACK-INS-011 461 Inselspital Bern (RPACK)
#> 2 1212 RPACK-INS-014 461 Inselspital Bern (RPACK)
#> 3 1213 RPACK-INS-015 461 Inselspital Bern (RPACK)
sT_subset5 <- subset_secuTrial(dat = sT, participant = participants,
centre = centres[2], exclude = FALSE)
#> If you changed any labels in the secuTrialdata object manually these will be reset to their original state.
get_participants(sT_subset5)
#> [1] mnppid mnpaid mnpctrid mnpctrname
#> <0 rows> (or 0-length row.names)