Learn R Programming

CorrMixed (version 0.1-1)

Spaghetti.Plot: Make a Spaghetti plot

Description

Makes a spaghetti plot, i.e., a plot that depicts the outcome as a function of time for each individual subject.

Usage

Spaghetti.Plot(Dataset, Outcome, Time, Id, Add.Profiles=TRUE, Add.Mean=TRUE, 
Add.Median=FALSE, Col=8, Lwd.Me=3, xlim, ylim, ...)

Arguments

Dataset
A data.frame that should consist of multiple lines per subject ('long' format).
Outcome
The name of the outcome variable.
Time
The name of the time indicator.
Id
The subject indicator.
Add.Profiles
Logical. Should the individual profiles be added? Default Add.Profiles=TRUE.
Add.Mean
Logical. Should a line that depicts the mean as a function of time be added? Default Add.Mean=TRUE.
Add.Median
Logical. Should a line that depicts the medean as a function of time be added? Default Add.Mean=FALSE.
Col
The color of the individual profiles. Default Col=8 (grey).
Lwd.Me
The line width of the lines with mean and/or median. Default Lwd.Me=3.
xlim
The (min, max) values for the x-axis.
ylim
The (min, max) values for the y-axis.
...
Other arguments to be passed to the plot() function.

References

Van der Elst, W., Molenberghs, G., Hilgers, R., & Heussen, N. (2015). Correlation in continuous monitoring of vital parameters - estimating reliability using linear mixed-effects models. Submitted.

Examples

Run this code
# Open data
data(Example.Data)

# Plot individual profiles + mean
Spaghetti.Plot(Dataset = Example.Data, Outcome = Outcome, Id=Id, Time = Time)

# Plot individual profiles + median
Spaghetti.Plot(Dataset = Example.Data, Outcome = Outcome, Id=Id, Time = Time,
Add.Mean = FALSE, Add.Median = TRUE)

Run the code above in your browser using DataLab