Learn R Programming

packHV (version 2.4)

plot_mm: Spaghetti plot and plot of the mean at each time

Description

Spaghetti plot and plot of the mean at each time

Usage

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,
  ...
)

Value

None

Arguments

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-axis

xlab

character sring, label of the time axis

ylab

character string, label of the y axis

main

character string, main title

lwd.spag

numeric, width of the spaghetti lines, 1 by default

lwd.mean

numeric, width of the mean lines, 4 by default

...

Other arguments to be passed in plot

Author

Hugo Varet on Anais Charles-Nelson's idea

Examples

Run this code
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")

Run the code above in your browser using DataLab