See the textbook for the R code and commands... It was necessary to use the stack() command to convert a wide format data frame to a long format data frame, or rather to create a long format data frame from a wide format data frame. See section 3.9.4 Reshaping data (covers stack() and melt() functions) See how melt() is used below to create dataframe t2 from dataframe textdata2.
> textData2 <- read.delim("C:/R/AndyField/TextMessages.dat", header = T) > names(textData2) [1] "Group" "Baseline" "Six_months" > t2 <- melt(textData2, id = c("Group"), measured = c("Baseline", "Six_months")) > names(t2) [1] "Group" "variable" "value" > names(t2)<-c("Group", "Time", "Grammar_Score") > names(t2) [1] "Group" "Time" "Grammar_Score"
> line <- ggplot(t2, aes(Time, Grammar_Score, colour = Group)) > line + stat_summary(fun.y = mean, geom="point") + stat_summary(fun.y = mean, geom = "line", aes(group = Group))
> line + stat_summary(fun.y = mean, geom="point") + stat_summary(fun.y = mean, geom = "line", aes(group = Group)) + stat_summary(fun.data = mean_cl_boot, geom = "errorbar", width = 0.2) + labs(x = "Time", y = "Mean Grammar Score", colour = "Group")