summary_crop | R Documentation |
Functions for cropping summarized cluster data.
summary_crop(object, ...)
## S3 method for class 'cluster_frequency'
summary_crop(object, top_n = 5L, min_count = 0, min_percent = 0, ...)
## S3 method for class 'medication_frequency'
summary_crop(
object,
top_n = 5L,
min_count = 0,
min_percent = 0,
scope = "cluster",
...
)
## S3 method for class 'comedication_count'
summary_crop(object, ...)
## S3 method for class 'timing_trajectory'
summary_crop(object, sample_n_individual = 100L, weighted_sample = TRUE, ...)
## S3 method for class 'timing_atc_group'
summary_crop(
object,
sample_n_individual = 100L,
weighted_sample = TRUE,
min_count = 0L,
...
)
## S3 method for class 'summary.medic'
summary_crop(object, which = "all", ...)
object |
The summary object to be cropped. |
... |
Additional arguments to be passed to the specific method. |
top_n |
integer. In the case of |
min_count |
integer. The minimum count of a cluster or medication to keep it in the summary. If 0, the default, the minimum count is zero, i.e. there is not a minimum count. |
min_percent |
numeric. The minimum percentage of a cluster or medication to keep it in the summary. If 0, the default, the minimum percentage is zero, i.e. there is not a minimum percentage. |
scope |
character. The scope of the summary crops |
sample_n_individual |
a logical or integer. If FALSE, no individual
timing trajectories are sampled. If integer, |
weighted_sample |
a logical, but only used if |
which |
A character vector specifying which summaries to crop. The options are "cluster_frequency", "medication_frequency", "comedication_count", "timing_trajectory", and "timing_atc_group". The default is "all". |
A summary object, which is a modified version of the input summary object.
cluster_frequency
summary cropExtracts the top top_n
clusters by count. If top_n
is Inf
, all clusters
are kept. If min_count
is greater than 0, clusters with a count less than
min_count
are removed. If min_percent
is greater than 0, clusters with a
percentage less than min_percent
are removed. The remaining clusters are
grouped into a "Remaining" cluster.
medication_frequency
summary cropExtracts the top top_n
medications by count. If top_n
is Inf
, all
medications are kept. If min_count
is greater than 0, medications with a
count less than min_count
are removed. If min_percent
is greater than 0,
medications with a percentage less than min_percent
are removed. The
remaining medications are grouped into a "Remaining" cluster.
The scope
argument determines the scope of the crop. If scope
is
"cluster", the crop is based on the percentage of medication in the cluster.
If scope
is "global", the crop is based on the percentage of all
medication.
comedication_count
summary cropTO DO
timing_trajectory
summary cropSamples sample_n_individual
individual timing trajectories. If
sample_n_individual
is Inf
, all individual timing trajectories are kept.
If weighted_sample
is TRUE
, the individual timing trajectories are
sampled weighted by the number of medications in the individual timing
trajectory.
timing_atc_group
summary cropSamples sample_n_individual
individual timing trajectories. If
sample_n_individual
is Inf
, all individual timing trajectories are kept.
If weighted_sample
is TRUE
, the individual timing trajectories are
sampled weighted by the number of medications in the individual timing
trajectory.
summary.medic
summary cropCrops multiple summaries. The which
argument is a character vector
specifying which summaries to crop. The options are "cluster_frequency",
"medication_frequency", "comedication_count", "timing_trajectory", and
"timing_atc_group". If which
is "all", all summaries are cropped.
The ...
argument is passed to the specific methods, e.g. top_n
and
min_count
are passed to cluster_frequency
and medication_frequency
.
summary
, cluster_frequency
,
medication_frequency
, comedication_count
,
timing_trajectory
, timing_atc_group
clust <- medic(
complications,
id = id,
atc = atc,
k = 3:5,
timing = first_trimester:third_trimester
)
# Crop the cluster frequency summary
clust |>
cluster_frequency() |>
summary_crop(top_n = 3)
clust |>
summary() |>
summary_crop(which = "cluster_frequency", top_n = 3)
# Crop the medication frequency summary
clust |>
medication_frequency() |>
summary_crop(top_n = 3)
clust |>
summary() |>
summary_crop(which = "medication_frequency", top_n = 3)
# Crop the co-medication count summary
clust |>
comedication_count() |>
summary_crop(min_count = 10)
clust |>
summary() |>
summary_crop(which = "comedication_count", min_count = 10)
# crop the timing trajectory summary
clust |>
timing_trajectory() |>
summary_crop()
clust |>
summary() |>
summary_crop(which = "timing_trajectory")
# crop the timing ATC group summary
clust |>
timing_atc_group() |>
summary_crop()
clust |>
summary() |>
summary_crop(which = "timing_atc_group")
# crop multiple summaries
clust |>
summary() |>
summary_crop(
which = c("cluster_frequency", "medication_frequency"),
top_n = 3
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.