screen_drug | R Documentation |
The
screen_drug()
function identifies and ranks the most frequently
reported drugs (by active ingredient) in a dataset.
screen_drug(.data, mp_data, freq_threshold = NULL, top_n = NULL)
.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 |
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.
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
.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.