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

metatools

R-CMD-check codecov Lifecycle: experimental R-CMD-check

The goal of metatools is to enable the use of metacore objects. Metatools can be used to build datasets or enhance columns in existing datasets as well as checking datasets against the metadata in metacore.

Installation

You can install the latest released version of metatools from CRAN with:

``` {r, eval = FALSE} install.packages("metatools")

And the current development version from [GitHub](https://github.com/pharmaverse/metatools) with:

``` {r, eval = FALSE}
devtools::install_github("pharmaverse/metatools")

Example

Here is a basic example of some functions to build datasets and create new columns.

library(metatools)
library(metacore)
library(haven)
library(dplyr)
load(metacore_example("pilot_ADaM.rda"))
metacore <- metacore %>%
  select_dataset("ADSL")
ds_list <- list(DM = read_xpt(metatools_example("dm.xpt")))
# Pull in columns from DM to be in ADSL
adsl <- build_from_derived(metacore, ds_list, predecessor_only = FALSE) 
adsl 

# Now we can make some new columns and converting columns into factors
adsl %>%
   select(USUBJID, AGE, ETHNIC) %>% 
   create_cat_var(metacore, AGE, AGEGR1, AGEGR1N) %>% #Add an AGEGR1 and AGEGR1N column
   convert_var_to_fct(metacore, ETHNIC) # Change ETHNIC to as factor 

Metatools can also be used to run checks

data <- read_xpt(metatools_example("adsl.xpt"))

# Checks can be run on a single column
check_ct_col(data, metacore, TRT01PN) # Checks column only contains control terminology
# Or across all the columns 
check_ct_data(data, metacore) %>%  # Checks control terminology for all columns 
check_variables(metacore) # Check all variables in the metadata are in the dataset and there aren't any extra columns 


pharmaverse/metatools documentation built on Jan. 24, 2025, 11:10 p.m.