lme: Plot colours based on variable?

Leo Mada via R-help <[email protected]>
Newsgroups gmane.comp.lang.r.general
Message-ID <DBAP192MB0956E139BFF599808E8BEA7784D8A@DBAP192MB0956.EURP192.PROD.OUTLOOK.COM>
Dear R-Users,

Is there a quick solution to plot colours based on a variable?

I tried something like this:

library(nlme)

plot(BodyWeight)

# Does NOT work!
colDiet = c(2:4)[BodyWeight$Diet]
plot(BodyWeight, col = colDiet)

# Wastes space
rat.fit = lme(weight ~ Time + Diet, data = BodyWeight, random = ~ Time|Rat)
plot(rat.fit, weight ~ Time | Rat + Diet)

Is there a quick way to base the colour on the Diet variable?

Many thanks,

Leonard


	[[alternative HTML version deleted]]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.