Spaghetti plot and plot of the mean at each time
plot_mm( formula, data, col.spag = 1, col.mean = 1, type = "spaghettis", tick.times = TRUE, xlab = NULL, ylab = NULL, main = "", lwd.spag = 1, lwd.mean = 4, ... )
formula
: obs~time+(group|id)
or obs~time+(1|id)
data
: data frame in which we can find obs
, time
, group
and id
col.spag
: vector of length nrow(data)
with colors (one for each individual)col.mean
: vector of length length(levels(group))
with colors (one for each group)type
: "spaghettis"
, "mean"
or "both"
tick.times
: boolean, TRUE
to display ticks at each observation time on the x-axisxlab
: character sring, label of the time axisylab
: character string, label of the y axismain
: character string, main titlelwd.spag
: numeric, width of the spaghetti lines, 1 by defaultlwd.mean
: numeric, width of the mean lines, 4 by default...
: Other arguments to be passed in plot
None
N=10 time=rep(1:4,N) obs=1.1*time + rep(0:1,each=2*N) + rnorm(4*N) my.data=data.frame(id=rep(1:N,each=4),time,obs,group=rep(1:2,each=N*2)) par(xaxs="i",yaxs="i") plot_mm(obs~time+(group|id),my.data,col.spag=my.data$group, col.mean=c("blue","red"),type="both",main="Test plot_mm")
Hugo Varet on Anais Charles-Nelson's idea
Useful links