Psych 670 Assignment - Feb 6, 2014

Load the file, which I've put in the top-level R folder for now.

load("sampDat.dat")
summary(subS$userid)
##           701           702           704           705           706 
##           750           449           750           750           748 
##           707           709           710          711L          712L 
##           730           746           748           697           749 
##          713L          714L          715L          716L          717L 
##           749           749           750           748           750 
##          718L          719L          720L           721           722 
##           750           750           750           748           750 
##          723L          724L           725           726           727 
##           750           750           748           750           744 
## exp1_hl28_006 exp1_hl28_010 exp1_hl28_014 exp1_hl28_018 exp1_hl28_022 
##           277           300           300           296           300 
## exp1_hk82_005 exp1_hl82_009 exp1_hl82_013 exp1_hl82_017 exp1_hl82_021 
##           300           300           300           298           299 
## exp1_hr28_004 exp1_hr28_016 exp1_hr28_020 exp1_hr28_024 exp1_hr82_003 
##           300           294           300           300           299 
## exp1_hr82_007 exp1_hr82_011 exp1_hr82_015 exp1_hr82_019 exp1_hr82_023 
##           300           299           299           298           300 
##        mss003        mss007        mss009        mss011        mss015 
##           299           299           299           300           296 
##        mss017        mss019        mss021        mss002        mss004 
##           300           299           296           300           298 
##        mss006        mss008        mss010        mss012        mss014 
##           292           299           299           298           296 
##        mss016        mss018 
##           300           294

Load stringr library to work with text more easily.
Use str_detect function to get logical vector indicating which rows have “exp” appearing somewhere in the userid column.
Use subset function to extract just these rows from subS.

library(stringr)
exp1 <- subset(subS, str_detect(subS$userid, "exp"))

Load ggplot2 library for plotting.
Make ggplot object with x=trialnum and y=angdiff from data=exp1.
Add stat_summary layer to get it to plot the mean y-values at each x-value instead of just plotting y, by setting fun.y = “mean”.
Set geom=“point” inside stat_summary, so it knows what kind of graph you want to make with those means.

library(ggplot2)
diffPlot = ggplot(exp1, aes(trialnum, angdiff)) + stat_summary(fun.y = "mean", 
    geom = "point")
diffPlot

plot of chunk unnamed-chunk-3