I'm not sure if this is exactly what you are looking for but I would
generally create an interaction plot using the lattice 'dotplot' with
type = c("p","a") so I get both the original data and the
lines
joining the averages for the different factor levels. I also prefer
the horizontal orientation to the vertical orientation. Combining all
these variations produces something like
dotplot(f2 ~ y | f1, groups = f3, aspect = 0.2, layout = c(1,2), type
= c("p","a"), pch = 21, strip = FALSE, strip.left = TRUE,
auto.key list(columns = 2, lines = TRUE))
On Wed, Oct 7, 2009 at 11:00 AM, Paul Chatfield <p.s.chatfield at
rdg.ac.uk> wrote:>
> I'm interested in plotting a y with an x factor as the combination of 2
> factors and colour with respect to a third, which the code below does with
> interaction.plot(). ?However, this is because I redefine the x to be 1
> factor. ?Is there a way of getting it to plot without redefining it, and
> ideally to not join up the lines BETWEEN levels a and b, but just join
those
> between after and before for one level of f3. ?I figure this could be done
> by manually drawing over blank lines using ?lines but am not sure what the
> coordinates would be and figured there is probably an easier way where
> someone has dealt with this before. ?Any thoughts greatly appreciated,
>
> Paul
>
> #####
>
> y<-rnorm(36)
> f1<-rep(c("after","before"), 18)
> f2<-rep(1:3,12)
> f3<-rep(1:2, each=18)
>
> ## Define new factor to be f1 and f3 for x axis - clumsy code, but gets its
> done;
>
> ff<-numeric(length(y))
> for (i in 1:length(y))
> {if (f1[i]=="a" & f3[i]==1) ff[i]<-"1, a"
> else if(f1[i]=="a" & f3[i]==2) ff[i]<-"2, a"
> else if(f1[i]=="b" & f3[i]==1) ff[i]<-"1, b"
> else ff[i]<-"2, b"}
>
> ## Plot of interest;
>
> interaction.plot(ff,f2,y)
> --
> View this message in context:
http://www.nabble.com/Plotting-1-covariate%2C-3-factors-tp25789442p25789442.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>