>But I don't want to plot random colors.
>...
> That's why I have this vector with length 24 - each one matches one line in
> the "npk" dataset.
... which is not what interaction.plot, or matplot, needs; it needs one per
line on the plot.
>How can I inform to the interaction.plot function the co
Iuri:
Your code as emailed reads:
##
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)) # plot
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="y
Hi,
I am trying to plot an interaction.plot with different color for each
level of a factor. It has an erratic behavior.
For example, it works for the first interaction.plot below, with the
example from the ALDA book, but not with the other plots, from the NPK
dataset:
# from http://www.ats.ucla
4 matches
Mail list logo