Learn R Programming

⚠️There's a newer version (0.2.6) of this package.Take me there.

dmtools

Installation

devtools::install_github("chachabooms/dmtools")
library(dmtools)

Overview

For checking the dataset from EDC in clinical trials. Notice, your dataset should have a postfix( _post ) or a prefix( pre_ ) in the names of variables. Column names should be unique.

  • date() - create object date, for check dates in the dataset
  • lab() - create object lab, for check lab results
  • wbc() - create object wbc, for check WBCs count: (all * relative) / 100 = absolute
  • short() - create object short to transform the dataset(different events in one column)
  • check() - check objects
  • get_result() - get the final result of object
  • choose_test() - filter the final result of check()
  • check_sites() - check objects of different sites
  • test_sites() - filter the final result of check_sites()
  • rename_dataset() - rename dataset

Usage

For example, you want to check laboratory values, you need to create the excel table like in the example.

  • age_min - whole number, >= number
  • age_max - if none, type Inf, <= number
  • sex - for both sex, use |
  • human_name - friendly name for analysis
  • name_lab_vals - analysis from the dataset, without postfix or prefix
  • name_is_norm - estimate from the dataset, without postfix or prefix
  • lab_vals_min - lower limit of normal, >=
  • lab_vals_max - upper limit of normal, <=
# "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 human_lab  name_lab      refs lab_vals is_norm vals_to_dbl
#> 1 01  19   f      gluc gluc_post 3.9 - 5.9      5.5    norm         5.5
#> 2 01  19   f       ast  ast_post    0 - 39       30    norm        30.0
#> 3 03  22   m       ast  ast_post    0 - 42       31    norm        31.0
#>   auto_norm
#> 1      norm
#> 2      norm
#> 3      norm

# mis - analysis, which has an incorrect estimate of the result
obj_lab %>% choose_test("mis")
#>   id age sex human_lab  name_lab      refs lab_vals is_norm vals_to_dbl
#> 1 02  20   m       ast  ast_post    0 - 42       48    norm        48.0
#> 2 03  22   m      gluc gluc_post 3.9 - 5.9      9.7    norm         9.7
#>   auto_norm
#> 1        no
#> 2        no

# skip - analysis, which has an empty value of the estimate
obj_lab %>% choose_test("skip")
#>   id age sex human_lab  name_lab      refs lab_vals is_norm vals_to_dbl
#> 1 02  20   m      gluc gluc_post 3.9 - 5.9      4.1    <NA>         4.1
#>   auto_norm
#> 1      <NA>
# dmtools can work with the dataset as strange_df
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 human_lab  name_lab      refs lab_vals is_norm vals_to_dbl
#> 1 01  19   f      gluc gluc_post 3.9 - 5.9      5,5    norm         5.5
#> 2 03  22   m       ast  ast_post    0 - 42       31    norm        31.0
#>   auto_norm
#> 1      norm
#> 2      norm

# Notice, if dmtools can't understand the value of lab_vals e.g. < 5, it puts Inf in the vals_to_dbl
obj_lab %>% choose_test("mis")
#>   id age sex human_lab  name_lab      refs lab_vals is_norm vals_to_dbl
#> 1 01  19   f       ast  ast_post    0 - 39      < 5    norm         Inf
#> 2 02  20   m       ast  ast_post    0 - 42       48    norm        48.0
#> 3 03  22   m      gluc gluc_post 3.9 - 5.9      9,7    norm         9.7
#>   auto_norm
#> 1        no
#> 2        no
#> 3        no

obj_lab %>% choose_test("skip")
#>   id age sex human_lab  name_lab      refs lab_vals is_norm vals_to_dbl
#> 1 02  20   m      gluc gluc_post 3.9 - 5.9      4,1    <NA>         4.1
#>   auto_norm
#> 1      <NA>

Copy Link

Version

Install

install.packages('dmtools')

Monthly Downloads

208

Version

0.2.4

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Konstantin Ryabov

Last Published

May 12th, 2020

Functions in dmtools (0.2.4)

calc_diff

Function for calculating the difference between two dates
run_tests

Run tests
run_tests.date

Run test
run_tests.lab

Run tests
check.default

Check
check_sites

Check sites
get_result.default

Get final result
lab

Create object lab
choose_test

Filter final result
choose_test.date

Filter final result
choose_test.lab

Filter final result
find_colnames

Find column names
choose_test.wbc

Filter final result
find_colnames.date

Find column names with dates
create_norm

Estimating laboratory values
dmtools

dmtools: package to validate data
to_dbl

Cast to double type
date

Create object date
wbc

Create object wbc
run_tests.short

Run tests
create_spec

For creating part of the specification
get_result

Get the final result
find_colnames.default

Find column names
test_sites

Test sites
short

Create object short
run_tests.wbc

Run tests
rename_dataset

For rename dataset
check

Check