| plot_profile | R Documentation |
Creates a profile plot showing individual subject trajectories with overlaid mean trajectory and standard deviation bands.
plot_profile(
y,
time_points = NULL,
blocks = NULL,
block_labels = NULL,
title = "Profile Plot",
xlab = "Time",
ylab = "Measurement",
ylim = NULL,
show_sd = TRUE,
individual_alpha = 0.3,
individual_color = "grey50",
mean_color = "blue",
sd_color = "red",
mean_lwd = 2
)
y |
Numeric matrix with n_subjects rows and n_time columns, or a data frame with measurements. |
time_points |
Optional numeric vector of time points for x-axis. Default uses 1:n_time or attempts to extract from column names. |
blocks |
Optional integer vector of block memberships for stratified plotting. If provided, creates separate panels for each block. |
block_labels |
Optional character vector of labels for blocks. |
title |
Plot title. Default "Profile Plot". |
xlab |
X-axis label. Default "Time". |
ylab |
Y-axis label. Default "Measurement". |
ylim |
Optional y-axis limits as c(min, max). |
show_sd |
Logical; if TRUE (default), show +/- 1 SD error bars. |
individual_alpha |
Alpha (transparency) for individual trajectories. Default 0.3. |
individual_color |
Color for individual trajectories. Default "grey50". |
mean_color |
Color for mean trajectory. Default "blue". |
sd_color |
Color for SD error bars. Default "red". |
mean_lwd |
Line width for mean trajectory. Default 2. |
This function provides a quick visual summary of longitudinal data showing:
Individual subject trajectories (light grey lines)
Mean trajectory across subjects (bold colored line)
+/- 1 standard deviation bands (error bars)
When blocks is provided, the plot is faceted by block membership,
allowing comparison of trajectories across treatment groups or other strata.
A ggplot2 object (invisibly). Called primarily for side effect (plotting).
data("bolus_inad")
# Basic profile plot
plot_profile(bolus_inad$y)
# With block stratification
plot_profile(bolus_inad$y, blocks = bolus_inad$blocks,
block_labels = c("2mg", "1mg"))
# Customized
plot_profile(bolus_inad$y,
time_points = seq(0, 44, by = 4),
title = "Bolus Counts Over Time",
xlab = "Hours", ylab = "Count")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.