
install.packages("dmtools")
# dev-version
devtools::install_github("KonstantinRyabov/dmtools")
library(dmtools)For checking the dataset from EDC in clinical trials. Notice, your dataset should have a postfix( _V1 ) or a prefix( V1_ ) in the names of variables. Column names should be unique.
date() - create object date to check dates in the
datasetlab() - create object lab to check lab reference
rangeshort() - create object short to reshape the dataset in
a tidy view.check() - check objectsget_result() - get the final result of objectchoose_test() - filter the final result of
check()rename_dataset() - rename the datasetFor example, you want to check laboratory values, you need to create the excel table like in the example.
|*column names without prefix or postfix
| AGELOW | AGEHIGH | SEX | LBTEST | LBORRES | LBNRIND | LBORNRLO | LBORNRHI | 
|---|---|---|---|---|---|---|---|
| 18 | 45 | f|m | Glucose | GLUC | GLUC_IND | 3.9 | 5.9 | 
| 18 | 45 | m | Aspartate transaminase | AST | AST_IND | 0 | 42 | 
| 18 | 45 | f | Aspartate transaminase | AST | AST_IND | 0 | 39 | 
| ID | AGE | SEX | GLUC_V1 | GLUC_IND_V1 | AST_V2 | AST_IND_V2 | 
|---|---|---|---|---|---|---|
| 01 | 19 | f | 5.5 | norm | 30 | norm | 
| 02 | 20 | m | 4.1 | NA | 48 | norm | 
| 03 | 22 | m | 9.7 | norm | 31 | norm | 
# "norm" and "no" it is an example, necessary variable for the estimate, get from the dataset
refs <- system.file("labs_refer.xlsx", package = "dmtools")
obj_lab <- lab(refs, ID, AGE, SEX, "norm", "no")
obj_lab <- obj_lab %>% check(df)
# ok - analysis, which has a correct estimate of the result
obj_lab %>% choose_test("ok")
#>   ID AGE SEX                 LBTEST LBTESTCD VISIT LBORNRLO LBORNRHI LBORRES
#> 1 01  19   f                Glucose     GLUC   _V1      3.9      5.9     5.5
#> 2 01  19   f Aspartate transaminase      AST   _V2      0.0     39.0      30
#> 3 03  22   m Aspartate transaminase      AST   _V2      0.0     42.0      31
#>   LBNRIND RES_TYPE_NUM IND_EXPECTED
#> 1    norm          5.5         norm
#> 2    norm         30.0         norm
#> 3    norm         31.0         norm
# mis - analysis, which has an incorrect estimate of the result
obj_lab %>% choose_test("mis")
#>   ID AGE SEX                 LBTEST LBTESTCD VISIT LBORNRLO LBORNRHI LBORRES
#> 1 02  20   m Aspartate transaminase      AST   _V2      0.0     42.0      48
#> 2 03  22   m                Glucose     GLUC   _V1      3.9      5.9     9.7
#>   LBNRIND RES_TYPE_NUM IND_EXPECTED
#> 1    norm         48.0           no
#> 2    norm          9.7           no
# skip - analysis, which has an empty value of the estimate
obj_lab %>% choose_test("skip")
#>   ID AGE SEX  LBTEST LBTESTCD VISIT LBORNRLO LBORNRHI LBORRES LBNRIND
#> 1 02  20   m Glucose     GLUC   _V1      3.9      5.9     4.1    <NA>
#>   RES_TYPE_NUM IND_EXPECTED
#> 1          4.1         norm| ID | AGE | SEX | V1_GLUC | V1_GLUC_IND | V2_AST | V2_AST_IND | 
|---|---|---|---|---|---|---|
| 01 | 19 | f | 5,5 | norm | < 5 | norm | 
| 02 | 20 | m | 4,1 | NA | 48 | norm | 
| 03 | 22 | m | 9,7 | norm | 31 | norm | 
# dmtools can work with the dataset as strange_df
# parameter is_post has value FALSE because a dataset has a prefix( V1_ ) in the names of variables
obj_lab <- lab(refs, ID, AGE, SEX, "norm", "no", is_post = F)
obj_lab <- obj_lab %>% check(strange_df)
# dmtools can understand the value with a comma like 6,6 
obj_lab %>% choose_test("ok")
#>   ID AGE SEX                 LBTEST LBTESTCD VISIT LBORNRLO LBORNRHI LBORRES
#> 1 01  19   f                Glucose     GLUC   V1_      3.9      5.9     5,5
#> 2 03  22   m Aspartate transaminase      AST   V2_      0.0     42.0      31
#>   LBNRIND RES_TYPE_NUM IND_EXPECTED
#> 1    norm          5.5         norm
#> 2    norm         31.0         norm
# Notice, if dmtools can't understand the value of lab_vals e.g. < 5, it puts Inf in the RES_TYPE_NUM
obj_lab %>% choose_test("mis")
#>   ID AGE SEX                 LBTEST LBTESTCD VISIT LBORNRLO LBORNRHI LBORRES
#> 1 01  19   f Aspartate transaminase      AST   V2_      0.0     39.0     < 5
#> 2 02  20   m Aspartate transaminase      AST   V2_      0.0     42.0      48
#> 3 03  22   m                Glucose     GLUC   V1_      3.9      5.9     9,7
#>   LBNRIND RES_TYPE_NUM IND_EXPECTED
#> 1    norm          Inf           no
#> 2    norm         48.0           no
#> 3    norm          9.7           no
obj_lab %>% choose_test("skip")
#>   ID AGE SEX  LBTEST LBTESTCD VISIT LBORNRLO LBORNRHI LBORRES LBNRIND
#> 1 02  20   m Glucose     GLUC   V1_      3.9      5.9     4,1    <NA>
#>   RES_TYPE_NUM IND_EXPECTED
#> 1          4.1         norm