screen_drug: Screening of Drugs

View source: R/screen_drug.R

screen_drugR Documentation

Screening of Drugs

Description

[Experimental] The screen_drug() function identifies and ranks the most frequently reported drugs (by active ingredient) in a dataset.

Usage

screen_drug(.data, mp_data, freq_threshold = NULL, top_n = NULL)

Arguments

.data

An drug data.table. See drug_

mp_data

An MP data.table. See mp_

freq_threshold

A numeric value indicating the minimum frequency (as a proportion) of cases where a drug must appear to be included in the results. Defaults to NULL.

top_n

An integer specifying the number of most frequently occurring drugs to return. Defaults to NULL.

Details

  • If freq_threshold is set (e.g., 0.05), the function filters drugs appearing in at least 5% of unique reports in .data.

  • If top_n is specified, only the most frequent n drugs are returned. If both freq_threshold and top_n are provided, only top_n is applied (a warning is raised in such cases).

  • Counts are computed at the case level, not the drug mention level. This means frequencies reflect the proportion of unique reports (cases) where a drug is mentioned, rather than the total mentions across all reports.

Value

A data.frame with the following columns:

  • ⁠Drug name⁠: The drug name.

  • DrecNo: The drug record number

  • N: The number of unique reports (cases) where the drug appears.

  • percentage: The percentage of total unique reports where the drug appears.

The results are sorted in descending order of percentage.

Examples

# Set up start
data.table::setDTthreads(1)

# Filter drugs appearing in at least 10% of reports
screen_drug(
  .data = drug_,
  mp_data = mp_,
  freq_threshold = 0.10
)

# Get the top 5 most reported drugs
screen_drug(
  .data = drug_,
  mp_data = mp_,
  top_n = 5
)

# nb: in the example datasets, not all drugs are recorded in mp_,
# leading to NAs in screen_drug output.

# Set up end
data.table::setDTthreads(0)

vigicaen documentation built on April 3, 2025, 8:55 p.m.