sdtm_assign: Derive an SDTM variable

View source: R/assign.R

sdtm_assignR Documentation

Derive an SDTM variable

Description

sdtm_assign() is an internal function packing the same functionality as assign_no_ct() and assign_ct() together but aimed at developers only. As a user please use either assign_no_ct() or assign_ct().

Usage

sdtm_assign(
  tgt_dat = NULL,
  tgt_var,
  raw_dat,
  raw_var,
  ct_spec = NULL,
  ct_clst = NULL,
  id_vars = oak_id_vars()
)

Arguments

tgt_dat

Target dataset: a data frame to be merged against raw_dat by the variables indicated in id_vars. This parameter is optional, see section Value for how the output changes depending on this argument value.

tgt_var

The target SDTM variable: a single string indicating the name of variable to be derived.

raw_dat

The raw dataset (dataframe); must include the variables passed in id_vars and raw_var.

raw_var

The raw variable: a single string indicating the name of the raw variable in raw_dat.

ct_spec

Study controlled terminology specification: a dataframe with a minimal set of columns, see ct_spec_vars() for details. This parameter is optional, if left as NULL no controlled terminology recoding is applied.

ct_clst

A codelist code indicating which subset of the controlled terminology to apply in the derivation. This parameter is optional, if left as NULL, all possible recodings in ct_spec are attempted.

id_vars

Key variables to be used in the join between the raw dataset (raw_dat) and the target data set (tgt_dat).

Value

The returned data set depends on the value of tgt_dat:

  • If no target dataset is supplied, meaning that tgt_dat defaults to NULL, then the returned data set is raw_dat, selected for the variables indicated in id_vars, and a new extra column: the derived variable, as indicated in tgt_var.

  • If the target dataset is provided, then it is merged with the raw data set raw_dat by the variables indicated in id_vars, with a new column: the derived variable, as indicated in tgt_var.


sdtm.oak documentation built on April 3, 2025, 9:37 p.m.