Learn R Programming

lava (version 1.4.1)

spaghetti: Spaghetti plot

Description

Spaghetti plot for longitudinal data

Usage

spaghetti(formula, data, id, type = "l", lty = 1, col = Col(1),
  trend = FALSE, trend.col = "darkblue", trend.alpha = 0.2,
  trend.lwd = 3, xlab = "Time", ylab = "", ...)

Arguments

formula
Formula (response ~ time)
data
data.frame
id
Id variable
type
Type (line 'l', stair 's', ...)
lty
Line type
col
Colour
trend
Add trend line
trend.col
Colour of trend line
trend.alpha
Transparency
trend.lwd
Trend line width
xlab
Label of X-axis
ylab
Label of Y-axis
...
Additional arguments to lower level arguments

Examples

Run this code
if (interactive() & require(mets)) {
K <- 5
y <- "y"%++%seq(K)
m <- lvm()
regression(m,y=y,x=~u) <- 1
regression(m,y=y,x=~s) <- seq(K)-1
regression(m,y=y,x=~x) <- "b"
d <- sim(m,500)
dd <- fast.reshape(d);
dd$num <- dd$num+rnorm(nrow(dd),sd=0.5) ## Unbalance
spaghetti(y~num,dd,id="id",lty=1,col=Col(1,.4),trend=TRUE,trend.col="darkblue")
}

Run the code above in your browser using DataLab