dmtools

CRAN status Build Status codecov

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

Installation

install.packages("dmtools")

# dev-version
devtools::install_github("KonstantinRyabov/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.

Usage

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

*column names without prefix or postfix

library(knitr)
library(dmtools)
library(dplyr)

refs <- system.file("labs_refer.xlsx", package = "dmtools")
refers <- readxl::read_xlsx(refs)
kable(refers, caption = "lab reference ranges")
ID <- c("01", "02", "03")
AGE <- c("19", "20", "22")
SEX <- c("f", "m", "m")
GLUC_V1 <- c("5.5", "4.1", "9.7")
GLUC_IND_V1 <- c("norm", NA, "norm")
AST_V2 <- c("30", "48", "31")
AST_IND_V2 <- c("norm", "norm", "norm")

df <- data.frame(
  ID, AGE, SEX,
  GLUC_V1, GLUC_IND_V1,
  AST_V2, AST_IND_V2,
  stringsAsFactors = F
)

kable(df, caption = "dataset")
# "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")

# mis - analysis, which has an incorrect estimate of the result
obj_lab %>% choose_test("mis")

# skip - analysis, which has an empty value of the estimate
obj_lab %>% choose_test("skip")
ID <- c("01", "02", "03")
AGE <- c("19", "20", "22")
SEX <- c("f", "m", "m")
V1_GLUC <- c("5,5", "4,1", "9,7")
V1_GLUC_IND <- c("norm", NA, "norm")
V2_AST <- c(" < 5", "48", "31")
V2_AST_IND <- c("norm", "norm", "norm")

strange_df <- data.frame(
  ID, AGE, SEX,
  V1_GLUC, V1_GLUC_IND,
  V2_AST, V2_AST_IND,
  stringsAsFactors = F
)

kable(strange_df, caption = "strange_dataset")
# 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")

# 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")

obj_lab %>% choose_test("skip")


chachabooms/dmtools documentation built on Feb. 1, 2023, 4:39 p.m.