I was trying to create a simple line graph of means and interactions. I have a DV (reading times) on the y-axis, one factor (Length) on the x-axis, and another as a grouping variable (position).
The syntax I used is below. The data plotted as single points on a line for each of the two Length conditions, but did not connect with lines between the two Length conditions. What am I missing in terms of syntax?
I am using R i386 2.15.2, and updated ggplot2 last week.
Here is a reproducible example
SubjectID <- c(101,101,101,101,101,101,101,101,102,102,102,102,102,102,102,102,
201,201,201,201,201,201,201,201,202,202,202,202,202,202,202,202)
Group <- c("PWA","PWA","PWA","PWA","PWA","PWA","PWA","PWA","PWA","PWA","PWA",
"PWA","PWA","PWA","PWA","PWA","Control","Control","Control",
"Control","Control","Control","Control","Control","Control",
"Control","Control","Control","Control","Control","Control",
"Control")
Length <- c(1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2)
Pos <- c(1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2)
ReadT <- c(6.7,7.6,6.4,7.9,5.4,6.4,6.3,7.4,6.9,7.2,6.7,7.4,5.7,6.1,6.5,7.8,
6.1,5.7,4.9,6.1,4.7,6.5,6.1,6.2,6.9,5.9,4.8,6.5,4.6,6.3,6.7,6.6)
data <- data.frame (SubjectID, Group,Length,Pos,ReadT)
data$Length <- factor(data$Length, order = TRUE,
levels = c(1,2),
labels = c("Length 1", "Length 2"))
data$Pos <- factor(data$Pos, order = TRUE,
levels = c(1,2),
labels = c("Position 1", "Position 2"))
qplot(Length, data=data, ReadT, geom=c("point", "line"),
stat="summary", fun.y=mean, group=Pos, colour=Pos,
facets = ~Group)