Learn R Programming

emcAdr (version 1.3)

combination_data_frame: Generate Matrix for Drug Combinations

Description

This function creates a logical data frame where each column represents a specific sub-combination of drugs derived from a given "cocktail." For each patient in the input data, it indicates (TRUE/FALSE) whether they were taking that specific combination based on the ATC hierarchy.

Usage

combination_data_frame(cocktail, upperBound, data)

Value

A Rcpp::DataFrame where:

  • Each column corresponds to a sub-combination of the input cocktail.

  • Each row corresponds to a patient in the input data.

  • Values are boolean indicators (represented as integers/logicals in R).

Arguments

cocktail

An integer vector of drug indices representing the full combination to be analyzed.

upperBound

An integer vector defining the ATC tree hierarchy bounds.

data

A Rcpp::DataFrame containing patient records. It must include a column "patientATC" which is a list of integer vectors representing the drugs each patient is taking.

Details

The function first generates all possible non-empty power-set combinations of the cocktail (e.g., for \(\{1, 2\}\), it generates \(\{1\}, \{2\}, \{1, 2\}\)).