screen_drug {vigicaen} | R Documentation |
Screening of Drugs
Description
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 |
mp_data |
An |
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 |
top_n |
An integer specifying the number of most frequently occurring drugs to return. Defaults to |
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 frequentn
drugs are returned. If bothfreq_threshold
andtop_n
are provided, onlytop_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)