The short()
can be useful for validation, if you need to reshape the dataset. You also need to create the excel document, where the name and number of columns can be any. If you have common columns, pass them to a parameter common_cols
of short()
. Notice, don’t write common columns in the excel document. If you have the extra information e.g. the understandable name of an analysis, pass it to a parameter extra
.
Some examples, where you can use short()
.
LBPERF | LBORRES |
---|---|
preg_yn | preg_res |
id | site | sex | preg_yn_e2 | preg_res_e2 | preg_yn_e3 | preg_res_e3 |
---|---|---|---|---|---|---|
01 | site 01 | f | y | neg | y | neg |
02 | site 02 | m | y | neg | y | pos |
03 | site 03 | f | y | neg | n | unnes |
preg <- system.file("preg.xlsx", package = "dmtools")
obj_short <- short(preg, id, "LBORRES", c("site", "sex"))
obj_short <- obj_short %>% check(df)
obj_short %>% get_result()
#> id site sex LBPERF LBORRES IDVAR VISIT
#> 1 01 site 01 f y neg preg_res _e2
#> 2 01 site 01 f y neg preg_res _e3
#> 3 02 site 02 m y neg preg_res _e2
#> 4 02 site 02 m y pos preg_res _e3
#> 5 03 site 03 f y neg preg_res _e2
#> 6 03 site 03 f n unnes preg_res _e3
CMTRT | CMDOSE |
---|---|
drug_type | drug_amount |
id | e2_drug_type | e2_drug_amount | e3_drug_type | e3_drug_amount |
---|---|---|---|---|
01 | type_one | 2 | type_one | 2 |
02 | type_two | 1 | type_two | 1 |
03 | type_one | 2 | type_one | 1 |
drug <- system.file("drug.xlsx", package = "dmtools")
# parameter is_post has value FALSE because a dataset has a prefix in the names of variables
obj_short <- short(drug, id, "CMTRT", is_post = F)
obj_short <- obj_short %>% check(df)
obj_short %>% get_result()
#> id CMTRT CMDOSE IDVAR VISIT
#> 1 01 type_one 2 drug_type e2_
#> 2 01 type_one 2 drug_type e3_
#> 3 02 type_two 1 drug_type e2_
#> 4 02 type_two 1 drug_type e3_
#> 5 03 type_one 2 drug_type e2_
#> 6 03 type_one 1 drug_type e3_
VSTEST_HR | VSTEST_RESP |
---|---|
hr | respr |
id | e2_hr | e2_respr | e3_hr | e3_respr |
---|---|---|---|---|
01 | 60 | 12 | 65 | 13 |
02 | 70 | 15 | 71 | 14 |
03 | 76 | 16 | 86 | 18 |
vf <- system.file("vf.xlsx", package = "dmtools")
obj_short <- short(vf, id, "VSTEST_HR", is_post = F)
obj_short <- obj_short %>% check(df)
obj_short %>% get_result()
#> id VSTEST_HR VSTEST_RESP IDVAR VISIT
#> 1 01 60 12 hr e2_
#> 2 01 65 13 hr e3_
#> 3 02 70 15 hr e2_
#> 4 02 71 14 hr e3_
#> 5 03 76 16 hr e2_
#> 6 03 86 18 hr e3_
LBORRES | LBNRIND | LBCLSIG | LBTEST |
---|---|---|---|
ast | ast_norm | ast_cl | Aspartate transaminase |
id | ast_e2 | ast_norm_e2 | ast_cl_e2 | ast_e3 | ast_norm_e3 | ast_cl_e3 | ae_yn_e5 | ae_desc_e5 |
---|---|---|---|---|---|---|---|---|
01 | 32 | norm | NA | 36 | norm | NA | no | NA |
02 | 56 | no | no | 80 | no | yes | yes | abnormal ast |
03 | 60 | no | yes | 32 | norm | NA | no | NA |
ae <- system.file("ae.xlsx", package = "dmtools")
obj_short <- short(ae, id, "LBNRIND", common_cols = c("ae_yn_e5", "ae_desc_e5"), extra = "LBTEST")
obj_short <- obj_short %>% check(df)
obj_short %>% get_result()
#> id ae_yn_e5 ae_desc_e5 LBORRES LBNRIND LBCLSIG IDVAR VISIT
#> 1 01 no <NA> 32 norm <NA> ast_norm _e2
#> 2 01 no <NA> 36 norm <NA> ast_norm _e3
#> 3 02 yes abnormal ast 56 no no ast_norm _e2
#> 4 02 yes abnormal ast 80 no yes ast_norm _e3
#> 5 03 no <NA> 60 no yes ast_norm _e2
#> 6 03 no <NA> 32 norm <NA> ast_norm _e3
#> LBTEST
#> 1 Aspartate transaminase
#> 2 Aspartate transaminase
#> 3 Aspartate transaminase
#> 4 Aspartate transaminase
#> 5 Aspartate transaminase
#> 6 Aspartate transaminase