Learn R Programming

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

dmtools

Installation

install.packages("dmtools")

# dev-version
devtools::install_github("chachabooms/dmtools")

library(dmtools)

Overview

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, for check dates in the dataset
  • lab() - create object lab, for check lab results
  • 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.

  • AGELOW - number, >= number
  • AGEHIGH - if none, type Inf, <= number
  • SEX - for both sex, use |
  • LBTEST - What was the lab test name?
  • LBORRES - What was the result of the result lab test?
  • LBNDIND - How [did/do] the reported values compare within the [reference/normal/expected] range?
  • LBORNRLO - What was the lower limit of the reference range for this lab test, >=
  • LBORNRHI - What was the high limit of the reference range for this lab test, <=
# "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 LBTESCD VISIT LBORNRLO LBORNRHI LBORRES LBNRIND
#> 1 01  19   f   gluc    gluc   _v1      3.9      5.9     5.5    norm
#> 2 01  19   f    ast     ast   _v2      0.0     39.0      30    norm
#> 3 03  22   m    ast     ast   _v2      0.0     42.0      31    norm
#>   RES_TYPE_NUM IND_EXPECTED
#> 1          5.5         norm
#> 2         30.0         norm
#> 3         31.0         norm

# mis - analysis, which has an incorrect estimate of the result
obj_lab %>% choose_test("mis")
#>   id age sex LBTEST LBTESCD VISIT LBORNRLO LBORNRHI LBORRES LBNRIND
#> 1 02  20   m    ast     ast   _v2      0.0     42.0      48    norm
#> 2 03  22   m   gluc    gluc   _v1      3.9      5.9     9.7    norm
#>   RES_TYPE_NUM IND_EXPECTED
#> 1         48.0           no
#> 2          9.7           no

# skip - analysis, which has an empty value of the estimate
obj_lab %>% choose_test("skip")
#>   id age sex LBTEST LBTESCD VISIT LBORNRLO LBORNRHI LBORRES LBNRIND
#> 1 02  20   m   gluc    gluc   _v1      3.9      5.9     4.1    <NA>
#>   RES_TYPE_NUM IND_EXPECTED
#> 1          4.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 LBTEST LBTESCD VISIT LBORNRLO LBORNRHI LBORRES LBNRIND
#> 1 01  19   f   gluc    gluc   _v1      3.9      5.9     5,5    norm
#> 2 03  22   m    ast     ast   _v2      0.0     42.0      31    norm
#>   RES_TYPE_NUM IND_EXPECTED
#> 1          5.5         norm
#> 2         31.0         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 LBTEST LBTESCD VISIT LBORNRLO LBORNRHI LBORRES LBNRIND
#> 1 01  19   f    ast     ast   _v2      0.0     39.0     < 5    norm
#> 2 02  20   m    ast     ast   _v2      0.0     42.0      48    norm
#> 3 03  22   m   gluc    gluc   _v1      3.9      5.9     9,7    norm
#>   RES_TYPE_NUM IND_EXPECTED
#> 1          Inf           no
#> 2         48.0           no
#> 3          9.7           no

obj_lab %>% choose_test("skip")
#>   id age sex LBTEST LBTESCD VISIT LBORNRLO LBORNRHI LBORRES LBNRIND
#> 1 02  20   m   gluc    gluc   _v1      3.9      5.9     4,1    <NA>
#>   RES_TYPE_NUM IND_EXPECTED
#> 1          4.1         <NA>

Copy Link

Version

Install

install.packages('dmtools')

Monthly Downloads

208

Version

0.2.5

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Konstantin Ryabov

Last Published

September 1st, 2020

Functions in dmtools (0.2.5)

check

Check
calc_diff

Function for calculating the difference between two dates
choose_test.lab

Filter final result
create_spec

For creating part of the specification
add_cols

Add columns if columns don't exist
choose_test.date

Filter final result
create_norm

Estimating laboratory values
check.default

Check
choose_test

Filter final result
check_sites

Check sites
list_parse

A list to a tibble.
meddra_auth

Get the token
run_tests.date

Run test
get_result

Get the final result
run_tests.lab

Run tests
rename_dataset

For rename dataset
run_tests.short

Run tests
find_colnames.default

Find column names
meddra_post

Create the post query
run_tests

Run tests
find_colnames

Find column names
date

Create object date
find_colnames.date

Find column names with dates
to_dbl

Cast to double type
short

Create object short
test_sites

Test sites
dmtools

dmtools: package to validate data
lab

Create object lab
get_result.default

Get final result