Creates lollipop charts for categorical data visualization with emphasis on clinical applications like patient timelines, treatment outcomes, and biomarker comparisons.
Usage
lollipop(
data,
dep,
group,
highlight,
sortBy = "original",
orientation = "vertical",
showValues = FALSE,
showMean = FALSE,
colorScheme = "default",
theme = "default",
pointSize = 3,
lineWidth = 1,
xlabel,
ylabel,
title,
width = 800,
height = 600
)
Arguments
- data
The data as a data frame.
- dep
The numeric variable for the values (lollipop heights/lengths).
- group
The categorical variable for grouping (lollipop categories).
- highlight
Specific level to highlight in the plot with different color/style.
- sortBy
How to sort the lollipops in the chart.
- orientation
Chart orientation (vertical or horizontal lollipops).
- showValues
Whether to display value labels on the lollipops.
- showMean
Whether to display a reference line at the mean value.
- colorScheme
Color scheme for the lollipops.
- theme
Overall theme/appearance of the plot.
- pointSize
Size of the lollipop points.
- lineWidth
Width of the lollipop stems.
- xlabel
Custom label for the x-axis.
- ylabel
Custom label for the y-axis.
- title
Custom title for the plot.
- width
Width of the plot in pixels.
- height
Height of the plot in pixels.
Value
A results object containing:
results$todo | a html | ||||
results$summary | a table | ||||
results$plot | an image |
Tables can be converted to data frames with asDF
or as.data.frame
. For example:
results$summary$asDF
as.data.frame(results$summary)
Examples
# Basic lollipop chart
lollipop(
data = clinical_data,
dep = "biomarker_level",
group = "patient_id"
)
#> Error: object 'clinical_data' not found
# Advanced lollipop with customization
lollipop(
data = clinical_data,
dep = "biomarker_level",
group = "patient_id",
highlight = "high_risk_patient",
sortBy = "value",
showValues = TRUE,
orientation = "horizontal"
)
#> Error: object 'clinical_data' not found