Learn R Programming

emcAdr (version 1.3)

remove_higher_cocktails: Filter out drug cocktails with high-level ATC classifications

Description

This function iterates through a collection of drug combinations (cocktails) and filters out those that have a ratio of "high-level" nodes (ATC codes with length <= 3) exceeding the specified threshold. This is useful for removing overly generic drug categories from results.

Usage

remove_higher_cocktails(
  solutions,
  ATC_name,
  ATC_length,
  find_last_occurence = TRUE,
  max_height_ratio = 0.5
)

Value

A Rcpp::DataFrame with the same columns as solutions, containing only the cocktails that met the max_height_ratio criteria.

Arguments

solutions

A Rcpp::DataFrame containing the results to filter. Must include columns: "score", "RR", "p_value", "n.patient.taking.C", "n.patient.taking.C.and.having.AE", and "Cocktail".

ATC_name

A vector of strings containing the ATC codes/names used for mapping.

ATC_length

An integer vector where each element represents the length (hierarchy level) of the corresponding ATC code in ATC_name.

find_last_occurence

Logical. If true (default), the mapping logic will look for the last occurrence of a drug name in the reference list.

max_height_ratio

A double (default 0.5) representing the maximum allowable proportion of high-level nodes (length <= 3) in a cocktail. Cocktails exceeding this ratio are removed.