Changes in accuracy over time

# Load the data
setwd("C:/Users/Christie/Downloads")
load("sampDat.dat")
data <- subS
rm("subS")

# Subset participants from experiment 1
d <- subset(data, grepl("exp", userid))
# Load required packages
library(plyr)
library(ggplot2)
library(splines)
# Compute median, absolute angular difference for each trial in each block
medErr.trial <- ddply(d, .(blocknum, trialnum), summarise, medErr = median(abs(angdiff)))

# Since the trial numbers are repeated in each block, I am creating a
# continuous trial number from 1 to 300, the total number of trials
ctrial <- seq(1, length(medErr.trial$blocknum), 1)
dts <- cbind(medErr.trial, ctrial)

# Scatter plot with a linear and cubic spline of 2 degrees of freedom fit
p <- ggplot(dts, aes(x = ctrial, y = medErr)) + geom_point() + theme_bw()
p <- p + geom_smooth(method = "lm", colour = "blue", size = 1.5)
p <- p + geom_smooth(method = "lm", formula = y ~ ns(x, 2), colour = "red", 
    size = 1.5)
p <- p + labs(title = "Median, absolute error by trial", x = "Trial Number", 
    y = "Median, absolute error")
p

plot of chunk unnamed-chunk-3