[R] Colors in interaction plots

S Ellison S.Ellison at LGCGroup.com
Thu Jan 17 14:10:26 CET 2013


I was unable to run your code; 'fac' is missing and npk$fac in teh interaction.plot returns NA.

> data(npk, package="MASS")
> fit <- by(npk, npk$block, function(bydata) fitted.values(lm(yield ~ N,
> data=bydata)))
> fit <- unlist(fit)
> interaction.plot(npk$N, npk$block, fit, xlab="N", 
> ylab="yield") # fake factor, numeric fac <- 
> c(rep(1,12),rep(2,12)) # plots everything in black 
> interaction.plot(npk$N, npk$block, fit, xlab="N", 
> ylab="yield",col=fac)
> cbind(npk$block,fac)
> # plots everything transparent
> fac <- as.factor(fac)
> interaction.plot(npk$N, npk$block, fit, xlab="N",
> ylab="yield",col=as.numeric(npk$fac))

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list