Sunday, June 5, 2011

R - conditional plot

  • coplot is a graphical method by which you can show how a response depends on a predictor given other predictors
  • cut(var, n) cuts a continuous variable into n intervals, you can also specify your own breakpoints (breaks=c()); the result of cut is a factor

example code:
> attach(iris)
> coplot(Sepal.Length~Petal.Length|Species, col=unclass(Species), panel=panel.smooth)


> coplot(Sepal.Length~Petal.Length | cut(Sepal.Width,4) * cut(Petal.Width,2), col=unclass(Species), panel=panel.smooth)

No comments :

Post a Comment