qplot(x=l2, y=dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, width=0.3)+#
    facet_grid(corp~data)
quartz()
qplot(x=l2, y=dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, width=0.3)+#
    facet_grid(corp~data)
pdat
qplot(x=l2, y=dur_mean, data=pdat, geom=c("line","point"),#
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F)
qplot(x=l2, y=dur_mean, data=pdat, geom=c("line","point"),#
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F) +facet_grid(corp~data)
qplot(x=l2, y=dur_mean, data=pdat, geom=c("line","point"),#
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, width=0.3) +facet_grid(corp~data)
qplot(x=l2, y=dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, width=0.3) +facet_grid(corp~data)
pdat$dur_max	<- pdat$dur_mean + pdat$dur_se#
pdat$dur_min	<- pdat$dur_mean - pdat$dur_se
qplot(x=l2, y=dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin=dur_min, ymax=dur_max,#
    shape=s2F, width=0.3) +facet_grid(corp~data)
qplot(x=l2, y=dur_mean, data=pdat, geom=c("line","point"),#
	ymin=dur_min, ymax=dur_max,#
    shape=s2F, width=0.3) +facet_grid(corp~data)
qplot(x=l2, y=dur_mean, data=pdat, geom=c("line","point"),#
    shape=s2F, width=0.3) +facet_grid(corp~data) + geom_errorbar(aes(ymin=dur_min, ymax=dur_max))
qplot(x=l2, y=dur_mean, data=pdat, geom=c("line","point"),#
    shape=s2F, width=0.3) +facet_grid(corp~data)
qplot(l2, dur_mean, data=pdat, geom=c("line","point"),#
    shape=s2F, width=0.3) +facet_grid(corp~data)
qplot(l2, dur_mean, data=pdat, geom=c("line","point"),#
    shape=s2F) +facet_grid(corp~data) +#
    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))
pdat
qplot(l2, dur_mean, data=pdat, geom=c("line","point"),#
    shape=s2F, width=0.3) +facet_grid(corp~data) +#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(2,3), legend=FALSE)+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")
#
qplot(l2, dur_mean, data=pdat, geom=c("line","point"),#
    shape=s2F, width=0.3) +facet_grid(corp~data) +#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(2,3), legend=FALSE)+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-3, ymax+3))+#
    theme_bw() + opts(legend.position="none")
#
qplot(l2, dur_mean, data=pdat, geom=c("line","point"),#
    shape=s2F, width=0.3) +facet_grid(corp~data) +#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
#    scale_shape_manual(   name="", values=c(2,3), legend=FALSE)+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-3, ymax+3))+#
    theme_bw() + opts(legend.position=c(0.3,0.4)) # "none"
#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"),#
    shape=s2F, width=0.3) +facet_grid(corp~data) +#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
#    scale_shape_manual(   name="", values=c(2,3), legend=FALSE)+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-3, ymax+3))+#
    theme_bw() + opts(legend.position=c(0.2,0.45)) # "none"#
pLeft
#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"),#
    shape=s2F, width=0.3) +facet_grid(corp~data) +#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-3, ymax+3))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pLeft
#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"),#
    shape=s2F, width=0.3) +facet_grid(corp~data) +#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pLeft
#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"),#
    shape=s2F, width=0.3) +facet_grid(corp~data) +#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pLeft
#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"),#
	ymin=dur_min, ymax=dur_max,#
    shape=s2F, width=0.3) +facet_grid(corp~data) +#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pLeft
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin=dur_min, ymax=dur_max,#
    shape=s2F, width=0.3) +facet_grid(corp~data) +#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pLeft
?geom_errorbar
pdat$ymin- pdat$ymax
pdat$ymin
pdat$dur_ymin- pdat$dur_ymax
pdat$dur_min - pdat$dur_max
c(pdat$dur_min - pdat$dur_max)<0
#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin=dur_min, ymax=dur_max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pLeft
asld
asld$main <- "       (Skip) -- (Non-Skip)"
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    data=s2F) +facet_grid(corp~main)
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data) +facet_grid(corp~main)
pRight
asld$main <- factor("       (Skip) -- (Non-Skip)")
asld
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data) +facet_grid(corp~main)
pRight
asld$main2 <- factor("       (Skip) -- (Non-Skip)")#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data) +facet_grid(corp~main2)
pRight
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) +#
    facet_grid(corp~main2) + # #
    scale_colour_manual(  name="", values="black")+ #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pRight
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) +#
    facet_grid(corp~main2)
pRight
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) +#
    facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pRight
#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) +#
    facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pRight
ybred
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) +#
    facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybred)+
    coord_cartesian(ylim=c(ymind-5, ymaxd+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pRight
asld$corp	<- factor(asld$corp, levels=levels(asld$corp)[2:1])#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) +#
    facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind-5, ymaxd+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pRight
levels(asld$corp)
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) +#
    facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind-5, ymaxd+5))+#
    theme_bw() + opts(legend.position=c(0.3,0.45)) # "none"#
pRight
asld
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind-5, ymaxd+5))+#
    theme_bw() + opts(legend.position=c(0.3,0.45)) # "none"#
pRight
#
asld$main2 <- factor("       (Skip) -- (Non-Skip)")#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd)+#
    theme_bw() + opts(legend.position=c(0.3,0.45)) # "none"#
pRight
#
#
asld$main2 <- factor("       (Skip) -- (Non-Skip)")#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.3,0.45)) # "none"#
pRight
#
#
asld$main2 <- factor("       (Skip) -- (Non-Skip)")#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey")#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.3,0.45)) # "none"#
pRight
#
#
asld$main2 <- factor("       (Skip) -- (Non-Skip)")#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey")#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.3,0.45)) # "none"#
pRight
#
#
asld$main2 <- factor("       (Skip) -- (Non-Skip)")#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.3,0.45)) # "none"#
pRight
#
asld$main2 <- factor("       (Skip) -- (Non-Skip)")#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.3,0.45)) # "none"#
pRight
#
asld$main2 <- factor("       (Skip) -- (Non-Skip)")#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
pRight
# plot Difference#
asld$main2 <- factor("       (Skip) -- (Non-Skip)")#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
pRight
ybred
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(1, 3)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1:2))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col =    3))
#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin=dur_min, ymax=dur_max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pLeft
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin=dur_min, ymax=dur_max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pLeft#
#
# plot Difference#
asld$main2 <- factor("       (Skip) -- (Non-Skip)")#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
pRight#
#
#
#dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(1, 3)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1:2))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col =    3))
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
asld
str(asld$main2)
asld[1,]
asld	<- rbind(asld[1,], asld)
asld
asld$main2[1]
asld$main2[1]	<- "error"
asld$main2 <- "       (Skip) -- (Non-Skip)"
asld	<- rbind(asld[1,], asld)
asld$main2[1]
asld$main2[1]	<- "error"
asld$main2	<- factor(asld$main2)
str(asld)
pRight <- qplot(l2, Difference, data=subset(asld, main2!="error"), geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
pRight
pRight <- qplot(l2, Difference, data=subset(asld, main2!="error"), geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3, facets=corp~main2) +# facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
pRight
#
SIM  	<- read.table("../sim.vers")[[1]]#
#SIM	<- "14a_newgoffid"#
#
CORP	<- c("SHUF","PSC275")  # c("SHUF","PSC275","PSC30")#
samp 	<- 0#
#
#
print(paste("sim-Version: ",SIM,sep=""))#
#
ASF  	<- DSF  <- ASL  <- DSL  <- ASLD  <- ASFD  <- list()#
ASLc	<- DSLc	<- ASLDc	<- list()#
for (ic in c(1:length(CORP)) ) {#
#
corp 	<- CORP[ic]#
print(paste("process ",corp," ...",sep=""))#
#
#------------------------------------------------------------------------------------#
# load simulated data#
#------------------------------------------------------------------------------------#
ifile1    <- paste("../",SIM,corp,"/seq.dat",sep="")#
incol	   <- c("id","sn","wn","let","dur","st1","ao1","l","f","p","firstlast","fn1st","SFC","FixNonWord","nFixOnWord","testreg","x12")#
a	       <- read.table(ifile1, sep="	", col.names=incol, na.strings="-999")#
# firstlast = codes first and last fixation in a sentence. 1 = first, 2 = last, 0 = all others#
# st1 (alternative: n_skp_wrds) = saccade type of the previous saccade (1 = forward, 0 = refixation, 2 = skipping, -1 = regression to last word, ..)#
# fn1st = fixation number in first pass; 1 = first fixation on the word in firstpass reading; 2 = second fixation on the word in firstpass reading; 0 = more-pass reading fixation#
# SFC = Anzahl der Fixationen auf dem Wort im firstpass. 1 = single fixation case, 2 = 2-fixation case#
# FixNonWord = Fixation Nr. n auf dem fixierten Wort (1. Fixation = 0)#
# nFixOnWord = Anzahl der Fixationen auf dem fixierten Wort wÃ¤hrend des Lesens dieses Satzes (1 Fixation = 0; bis ...)#
#
#
#------------------------------------------------------------------------------------#
# add corpus info: nw, l2, f2, p2#
#------------------------------------------------------------------------------------#
ifile2    <- paste("../",SIM,corp,"/freq.dat",sep="")#
exp       <- read.table(ifile2)#
depvars   <- c("d1","d2","d0","trt", "p0","p2","p3","rgc")#
if (dim(exp)[2]==18) agg <- "pW"#
if (dim(exp)[2]==19) agg <- "pSW"#
if (agg=="pW" ) ivars <- c("sd1", "sd2", "sd0", "strt")#
if (agg=="pSW") ivars <- c("id",  "sn" , "wn" , "PSCsn","PSCwn")#
names(exp)	<- c("sn","wn","l","f","p", depvars, ivars, "nw")#
if (agg=="pW" ) exp <- exp[, !names(exp)%in%ivars ]#
word      <- exp[, !names(exp)%in%depvars]#
exp       <- exp[,  names(exp)%in%depvars]#
word[, c("l2","f2","p2")] <- rbind( word[2:nrow(word), c("l","f","p")], c(NA,NA,NA)  )#
word[word$wn==word$nw, c("l2","f2","p2")] <- c(NA, NA, NA)#
#match corpus info to data#
if (agg=="pW" ) did       <-                     a$sn*100 +    a$wn#
if (agg=="pW" ) cid       <-                  word$sn*100 + word$wn#
if (agg=="pSW") did       <-    a$id*100000 +    a$sn*100 +    a$wn # valid for id <= 999#
if (agg=="pSW") cid       <- word$id*100000 + word$sn*100 + word$wn#
idx_isw   <- match(did, cid)#
cvars     <- c("nw","l2","f2","p2")#
a[,cvars] <- word[idx_isw,cvars]#
#------------------------------------------------------------------------------------#
#
#------------------------------------------------------------------------------------#
# data processing: define variables + data selection#
#------------------------------------------------------------------------------------#
# find fixations before skip & before non-skip#
a$wn2     <- c( a$wn[2:nrow(a)], NA )#
a$wn2[a$firstlast==2] <- NA#
a$wn1     <- c( NA, a$wn[1:(nrow(a)-1)] )#
a$wn1[a$firstlast==1] <- NA#
#
a$s2      <- ifelse( a$wn2 > a$wn+1, 1, 0 )#
a$s2F     <- factor(a$s2)#
levels(a$s2F) <- c("before non-skip","before skip")#
#
# determine freq classes for plotting#
#BRE  <- c(-Inf, 10^seq(0,4,0.5), Inf)#
BRE  <- c(-Inf,10,100,1000,10000,Inf)#
a$f2C  <- cut(a$f2, breaks=BRE)#
levels(a$f2C)	<- c(1:(length(BRE)-1))#
a$f2C	<- as.numeric(as.character(a$f2C))#
#
# filter fixations#
nrow(a)#
a <- subset(a, fn1st!=0)        # find firstpass fixations#
nrow(a)#
a <- subset(a, wn!=1 & wn<nw-1) # remove fixations on first and last word per sentence#
nrow(a)#
a <- subset(a, firstlast==0)     # remove first & last fixation per sentence#
nrow(a)#
#
#
#i1st <- subset(a, FixNonWord==0)     # initial fixation case#
#s1st <- subset(a, SFC==1)            # single fixation case#
#x1st <- subset(a, SFC==1 & wn2>wn)   # SFC + forward-directed outgoing saccade#
x1st <- subset(a, SFC==1 & wn1==wn-1 & wn2>wn) # SFC + last word was fixated + forward-directed outgoing saccade#
sim   <- x1st#
nrow(sim)#
rm(a)#
#
#------------------------------------------------------------------------------------#
# load experimental data#
#------------------------------------------------------------------------------------#
ipath <- "/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/"#
ifile <- paste(corp,"_abc_iR1st.rda",sep="")#
#ifile <- "PSC275_abc_xB1st.rda" # -> additional: binocular criterium#
load(file=paste(ipath,corp,"_",samp,"/",ifile,sep=""))#
b$l2 <- 1/b$l2#
dat <- subset(b, wn1.x==wn-1 & wn2.x>wn)#
dat <- dat[, c("dur","s2","l2","f2") ]#
nrow(dat)#
#
rm(a,b,c)#
#
# define variables#
#skipping#
dat$s2F         <- factor(dat$s2)#
levels(dat$s2F) <- c("before non-skip","before skip")#
# freq classes#
#BRE  <- c(-Inf, 10^seq(0,4,0.5), Inf)#
BRE  <- c(-Inf,10,100,1000,10000,Inf)#
dat$f2C	<- cut(10^dat$f2, breaks=BRE)#
levels(dat$f2C)	<- c(1:(length(BRE)-1))#
dat$f2C	<- as.numeric(as.character(dat$f2C))#
#
#------------------------------------------------------------------------------------#
#### average per l, f, p of the next word#
#------------------------------------------------------------------------------------#
#
#----------------------------------------------------------------#
# 1) aggregate#
#----------------------------------------------------------------#
#
#length#
aml <- melt(sim, id=c("l2" ,"s2F"), measure=c("dur")) # a = SWIFT#
dml <- melt(dat, id=c("l2" ,"s2F"), measure=c("dur")) # d = Experiment#
aml <- subset(aml, l2<11)#
dml <- subset(dml, l2<11)#
asl <- data.frame(cast(aml, l2 + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsl <- data.frame(cast(dml, l2 + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asld<- data.frame(cast(aml, l2 ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsld<- data.frame(cast(dml, l2 ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asld$data <- "Simulation"#
dsld$data <- "Experiment"#
asld      <- rbind(asld, dsld)#
asld$Difference   <- asld$before.skip_mean - asld$before.non.skip_mean#
# check!! formula for non-paired t.test!!#
asld$se           <- sqrt((asld$before.skip_se^2 + asld$before.non.skip_se^2)/2)#
#
#freq#
amf <- melt(sim, id=c("f2C","s2F"), measure=c("dur"))#
dmf <- melt(dat, id=c("f2C","s2F"), measure=c("dur"))#
asf <- data.frame(cast(amf, f2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsf <- data.frame(cast(dmf, f2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asfd<- data.frame(cast(amf, f2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsfd<- data.frame(cast(dmf, f2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asfd$data <- "Simulation"#
dsfd$data <- "Experiment"#
asfd      <- rbind(asfd, dsfd)#
asfd$Difference   <- asfd$before.skip_mean - asfd$before.non.skip_mean#
asfd$se           <- sqrt((asfd$before.skip_se^2 + asfd$before.non.skip_se^2)/2)#
#
#
#length#
sim <- subset(sim, l2<11)#
dat <- subset(dat, l2<11)#
sim$l2C	<- cut(sim$l2, b=c(0,6.5,8.5,22))#
levels(sim$l2C)	<- c("Short Words\n[2-6 let]","Middle Length\n[7-8]","Long Words\n[8-10 let]")#
dat$l2C	<- cut(dat$l2, b=c(0,6.5,8.5,22))#
levels(dat$l2C)	<- c("Short Words\n[2-6 let]","Middle Length\n[7-8]","Long Words\n[8-10 let]")#
amlC <- melt(sim, id=c("l2C" ,"s2F"), measure=c("dur")) # a = SWIFT#
dmlC <- melt(dat, id=c("l2C" ,"s2F"), measure=c("dur")) # d = Experiment#
aslC <- data.frame(cast(amlC, l2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dslC <- data.frame(cast(dmlC, l2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asldC<- data.frame(cast(amlC, l2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsldC<- data.frame(cast(dmlC, l2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asldC$data <- "Simulation"#
dsldC$data <- "Experiment"#
asldC      <- rbind(asldC, dsldC)#
asldC$Difference   <- asldC$before.skip_mean - asldC$before.non.skip_mean#
# check!! formula for non-paired t.test!!#
asldC$se           <- sqrt((asldC$before.skip_se^2 + asldC$before.non.skip_se^2)/2)#
#
#
#
if (corp=="SHUF")	corp1	<- "Shuffled Text"#
if (corp=="PSC275")	corp1	<- "Normal Text"#
asf$corp <- dsf$corp <- asl$corp <- dsl$corp <- asfd$corp <- asld$corp <- corp1#
aslC$corp <- dslC$corp <- asldC$corp	<- corp1#
#
ASF[[ic]] <- asf#
DSF[[ic]] <- dsf#
ASL[[ic]] <- asl#
DSL[[ic]] <- dsl#
#
ASLD[[ic]] <- asld#
ASFD[[ic]] <- asfd#
#
#
ASLc[[ic]] <- aslC#
DSLc[[ic]] <- dslC#
ASLDc[[ic]] <- asldC#
#
} # for (ic in 1:length(corp)) {#
#
#
rm(asf,dsf,  asl,dsl,  asld,asfd,   aslC,dslC,asldC)#
asf  <- ASF[[1]]#
dsf  <- DSF[[1]]#
asl  <- ASL[[1]]#
dsl  <- DSL[[1]]#
asfd <- ASFD[[1]]#
asld <- ASLD[[1]]#
aslC <- ASLc[[1]]#
dslC <- DSLc[[1]]#
asldC<- ASLDc[[1]]#
if (length(CORP)>1) for (i in 2:length(CORP)) {#
  asf <- rbind(asf, ASF[[i]])#
  dsf <- rbind(dsf, DSF[[i]])#
  asl <- rbind(asl, ASL[[i]])#
  dsl <- rbind(dsl, DSL[[i]])#
#
  asfd <- rbind(asfd, ASFD[[i]])#
  asld <- rbind(asld, ASLD[[i]])#
#
  aslC <- rbind(aslC, ASLc[[i]])#
  dslC <- rbind(dslC, DSLc[[i]])#
  asldC<- rbind(asldC, ASLDc[[i]])#
}#
#
skipLabel	<- c("non-skip","before-skip")#
levels(asl$s2F)	<- skipLabel#
levels(asf$s2F)	<- skipLabel#
levels(dsl$s2F)	<- skipLabel#
levels(dsf$s2F)	<- skipLabel#
#
levels(aslC$s2F)	<- skipLabel#
levels(dslC$s2F)	<- skipLabel#
#
#
asl$corp	<- factor(asl$corp)#
asf$corp	<- factor(asf$corp)#
dsl$corp	<- factor(dsl$corp)#
dsf$corp	<- factor(dsf$corp)#
asld$corp	<- factor(asld$corp)#
asfd$corp	<- factor(asfd$corp)#
#
aslC$corp	<- factor(aslC$corp)#
dslC$corp	<- factor(dslC$corp)#
asldC$corp	<- factor(asldC$corp)#
#
asl$corp	<- factor(asl$corp, levels=levels(asl$corp)[c(2,1)])#
asf$corp	<- factor(asf$corp, levels=levels(asf$corp)[c(2,1)])#
dsl$corp	<- factor(dsl$corp, levels=levels(dsl$corp)[c(2,1)])#
dsf$corp	<- factor(dsf$corp, levels=levels(dsf$corp)[c(2,1)])#
#
asld$corp	<- factor(asld$corp, levels=levels(asld$corp)[c(2,1)])#
asfd$corp	<- factor(asfd$corp, levels=levels(asfd$corp)[c(2,1)])#
#
aslC$corp	<- factor(aslC$corp , levels=levels(aslC$corp )[c(2,1)])#
dslC$corp	<- factor(dslC$corp , levels=levels(dslC$corp )[c(2,1)])#
asldC$corp	<- factor(asldC$corp, levels=levels(asldC$corp)[c(2,1)])#
#
#
print("aggregate & plotting ...")#
#----------------------------------------------------------------#
# 2) plot#
#----------------------------------------------------------------#
#----------------------------------------------------------------#
# 2b) Schwarz - Weiß#
#----------------------------------------------------------------#
ymin  <- floor(   min(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ymax  <- ceiling( max(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ybre  <- seq(ymin, ymax, by=20)#
asl$data	<- "Simulation"#
dsl$data	<- "Experiment"#
sl			<- rbind(asl, dsl)#
sl$data		<- factor(sl$data)#
# Experiment#
p.dnl <- qplot(x=l2, y=dur_mean, data=subset(dsl,corp=="Normal Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Experiment")+#
    scale_colour_manual(  name="", values="grey", legend=FALSE)+#
    scale_shape_manual(   name="", values=c(2,3))+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position=c(1.1,0.02))#
p.dsl <- qplot(x=l2, y=dur_mean, data=subset(dsl,corp=="Shuffled Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Experiment")+#
    scale_colour_manual(  name="", values="grey", legend=FALSE)+#
    scale_shape_manual(   name="", values=c(2,3))+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
#
# Simulation#
p.anl <- qplot(x=l2, y=dur_mean, data=subset(asl,corp=="Normal Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Simulation")+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(2,3), legend=FALSE)+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
p.asl <- qplot(x=l2, y=dur_mean, data=subset(asl,corp=="Shuffled Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Simulation")+#
    scale_colour_manual(  name="", values="black", legend=FALSE)+#
    scale_shape_manual(   name="", values=c(2,3))+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
#
#
ymind  <- floor(   min(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
ymaxd  <- ceiling( max(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
#ymax  <- ymax + 20#
ybred  <- seq(ymind, ymaxd, by=25)#
asld$data	<- factor(asld$data)#
p.dnld <- qplot(x=l2, y=Difference, data=subset(asld,corp=="Normal Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	colour=data, width=0.3,#
	main="       (Skip) -- (Non-Skip)")+#
	scale_colour_manual(  name="", values=c("grey","black"))+#
	scale_x_continuous(name="         Word Length [let]")+#
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(0.1,0.02))#
p.dsld <- qplot(x=l2, y=Difference, data=subset(asld,corp=="Shuffled Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	colour=data, width=0.3, #
	main="       (Skip) -- (Non-Skip)") + #
	scale_colour_manual(    name="", values=c("grey","black"), legend=FALSE) +#
	scale_linetype_manual(name="", values=c(4,2))+#
	scale_x_continuous(name="         Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position="none")#
#
levels(asldC$corp)	<- c("Shuffled","Normal")#
levels(asldC$l2C)	<- c("short [2-6]","Middle Length\n[7-8]","long [9-10]")#
#dev.off()#
quartz(width=3.5,height=3)#
print(  p.sub <- qplot(x=corp, y=Difference, fill=data, facets=.~l2C,#
	xlab="      ", ylab="", ymin=Difference-se, ymax=Difference+se,#
	data=subset(asldC,l2C!="Middle Length\n[7-8]"), geom=c("bar","errorbar"), position="dodge") + #
	geom_hline(yintercept=0) + scale_fill_grey(name="") + theme_bw() + #
	opts(legend.position=c(0.35,0.8))   )#c(0.7,1.1)#
ggsave(paste("skipsimple2mLc_SW_bar_",samp,".eps",sep=""))#
#
dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(100, 100)))#
#
grid.text("Normal Text"  , 0.99, 0.75, gp=gpar(fontsize=14), rot=270)#
grid.text("Shuffled Text", 0.99, 0.25, gp=gpar(fontsize=14), rot=270)#
#
#
print(p.dnl , vp = viewport(layout.pos.row =  1: 50, layout.pos.col =  1: 33))#
print(p.anl , vp = viewport(layout.pos.row =  1: 50, layout.pos.col = 33: 65))#
print(p.dnld, vp = viewport(layout.pos.row =  1: 50, layout.pos.col = 65: 98))#
#
print(p.dsl , vp = viewport(layout.pos.row = 51:100, layout.pos.col =  1: 33))#
print(p.asl , vp = viewport(layout.pos.row = 51:100, layout.pos.col = 33: 65))#
print(p.dsld, vp = viewport(layout.pos.row = 51:100, layout.pos.col = 65: 98))#
#
#print(p.sub, vp = viewport(layout.pos.row = 55:82, layout.pos.col = 72:98))#
#
#
dev.copy2eps(file=paste("skipsimple2mLc_SW_",samp,"c.eps",sep=""))#
#
#
#
#--------------------#
# use facet_grid()#
#--------------------#
asld$corp	<- factor(asld$corp, levels=levels(asld$corp)[2:1])#
# combine data#
pdat	<- rbind(asl, dsl)#
pdat$s2F	<- factor(pdat$s2F)#
pdat$corp	<- factor(pdat$corp)#
pdat$dur_max	<- pdat$dur_mean + pdat$dur_se#
pdat$dur_min	<- pdat$dur_mean - pdat$dur_se#
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin=dur_min, ymax=dur_max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
pLeft#
#
# plot Difference#
asld$main2 <- "       (Skip) -- (Non-Skip)"#
#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
pRight#
#
#
#dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
pdat	<- rbind(asl, dsl)#
pdat$corp	<- factor(pdat$corp, levels=levels(pdat$corp)[2:1])
pdat$s2F	<- factor(pdat$s2F)#
pdat$corp	<- factor(pdat$corp)#
pdat$dur_max	<- pdat$dur_mean + pdat$dur_se#
pdat$dur_min	<- pdat$dur_mean - pdat$dur_se#
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin=dur_min, ymax=dur_max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft#
#
# plot Difference#
asld$main2 <- "       (Skip) -- (Non-Skip)"#
#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) -- (Non-Skip)",#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)",#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="")+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)",#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape(   name="", values=c(2,3))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)",#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape_manual(   name="", values=c(2,3))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
x
x<-1:21
qplot(x,x,geom="point",shape=x)
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)",#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape_manual(   name="", values=c(2,3))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin=dur_min, ymax=dur_max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)",#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape_manual(   name="", values=c(2,3))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin=dur_min, ymax=dur_max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)",#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape_manual(   name="", values=c(1,2))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin=dur_min, ymax=dur_max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)",#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape_manual(   name="", values=c(1,5))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
quartz(width=9*0.7, height=6*0.7)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
# combine data#
pdat	<- rbind(asl, dsl)#
pdat$corp	<- factor(pdat$corp, levels=levels(pdat$corp)[2:1])#
pdat$s2F	<- factor(pdat$s2F)#
pdat$corp	<- factor(pdat$corp)#
pdat$max	<- pdat$dur_mean + pdat$dur_se#
pdat$min	<- pdat$dur_mean - pdat$dur_se
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin=min, ymax=max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"
pLeft
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"), #"errorbar",#
	ymin=min, ymax=max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft
pLeft
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft
pLeft
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft
pLeft
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","errorbar","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"
pLeft
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point","errorbar"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft
pLeft
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)",#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape_manual(   name="", values=c(1,5))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,18))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)",#
    shape=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape_manual(   name="", values=c(1,2))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,18))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)",#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_shape_manual(   name="", values=c(1,2))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,18))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)",#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_linetype_manual(   name="", values=c(2,3))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)",#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_linetype_manual(   name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F, linetype=data) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)",#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
#    scale_linetype_manual(   name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F, linetype=data) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
#    scale_linetype_manual(   name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F, linetype=data) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45), legend.direction="horizontal") # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
#    scale_linetype_manual(   name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F, linetype=data) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45), legend.direction="horizontal") # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
#    scale_linetype_manual(   name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F, linetype=data) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.45)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
#    scale_linetype_manual(   name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F, linetype=data) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.25)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
#    scale_linetype_manual(   name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.35,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F, linetype=data) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.25)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
#    scale_linetype_manual(   name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F, linetype=data) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.25,0.25)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_linetype_manual( name="" ) +#name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_linetype( name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F, linetype=data) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.85,0.3)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_linetype( name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F, linetype=data) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.35,0.8)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_linetype( name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F, linetype=data) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.3,0.85)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_linetype( name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
SIM  	<- read.table("../sim.vers")[[1]]#
#SIM	<- "14a_newgoffid"#
#
CORP	<- c("SHUF","PSC275")  # c("SHUF","PSC275","PSC30")#
samp 	<- 0#
#
#
print(paste("sim-Version: ",SIM,sep=""))#
#
ASF  	<- DSF  <- ASL  <- DSL  <- ASLD  <- ASFD  <- list()#
ASLc	<- DSLc	<- ASLDc	<- list()#
for (ic in c(1:length(CORP)) ) {#
#
corp 	<- CORP[ic]#
print(paste("process ",corp," ...",sep=""))#
#
#------------------------------------------------------------------------------------#
# load simulated data#
#------------------------------------------------------------------------------------#
ifile1    <- paste("../",SIM,corp,"/seq.dat",sep="")#
incol	   <- c("id","sn","wn","let","dur","st1","ao1","l","f","p","firstlast","fn1st","SFC","FixNonWord","nFixOnWord","testreg","x12")#
a	       <- read.table(ifile1, sep="	", col.names=incol, na.strings="-999")#
# firstlast = codes first and last fixation in a sentence. 1 = first, 2 = last, 0 = all others#
# st1 (alternative: n_skp_wrds) = saccade type of the previous saccade (1 = forward, 0 = refixation, 2 = skipping, -1 = regression to last word, ..)#
# fn1st = fixation number in first pass; 1 = first fixation on the word in firstpass reading; 2 = second fixation on the word in firstpass reading; 0 = more-pass reading fixation#
# SFC = Anzahl der Fixationen auf dem Wort im firstpass. 1 = single fixation case, 2 = 2-fixation case#
# FixNonWord = Fixation Nr. n auf dem fixierten Wort (1. Fixation = 0)#
# nFixOnWord = Anzahl der Fixationen auf dem fixierten Wort wÃ¤hrend des Lesens dieses Satzes (1 Fixation = 0; bis ...)#
#
#
#------------------------------------------------------------------------------------#
# add corpus info: nw, l2, f2, p2#
#------------------------------------------------------------------------------------#
ifile2    <- paste("../",SIM,corp,"/freq.dat",sep="")#
exp       <- read.table(ifile2)#
depvars   <- c("d1","d2","d0","trt", "p0","p2","p3","rgc")#
if (dim(exp)[2]==18) agg <- "pW"#
if (dim(exp)[2]==19) agg <- "pSW"#
if (agg=="pW" ) ivars <- c("sd1", "sd2", "sd0", "strt")#
if (agg=="pSW") ivars <- c("id",  "sn" , "wn" , "PSCsn","PSCwn")#
names(exp)	<- c("sn","wn","l","f","p", depvars, ivars, "nw")#
if (agg=="pW" ) exp <- exp[, !names(exp)%in%ivars ]#
word      <- exp[, !names(exp)%in%depvars]#
exp       <- exp[,  names(exp)%in%depvars]#
word[, c("l2","f2","p2")] <- rbind( word[2:nrow(word), c("l","f","p")], c(NA,NA,NA)  )#
word[word$wn==word$nw, c("l2","f2","p2")] <- c(NA, NA, NA)#
#match corpus info to data#
if (agg=="pW" ) did       <-                     a$sn*100 +    a$wn#
if (agg=="pW" ) cid       <-                  word$sn*100 + word$wn#
if (agg=="pSW") did       <-    a$id*100000 +    a$sn*100 +    a$wn # valid for id <= 999#
if (agg=="pSW") cid       <- word$id*100000 + word$sn*100 + word$wn#
idx_isw   <- match(did, cid)#
cvars     <- c("nw","l2","f2","p2")#
a[,cvars] <- word[idx_isw,cvars]#
#------------------------------------------------------------------------------------#
#
#------------------------------------------------------------------------------------#
# data processing: define variables + data selection#
#------------------------------------------------------------------------------------#
# find fixations before skip & before non-skip#
a$wn2     <- c( a$wn[2:nrow(a)], NA )#
a$wn2[a$firstlast==2] <- NA#
a$wn1     <- c( NA, a$wn[1:(nrow(a)-1)] )#
a$wn1[a$firstlast==1] <- NA#
#
a$s2      <- ifelse( a$wn2 > a$wn+1, 1, 0 )#
a$s2F     <- factor(a$s2)#
levels(a$s2F) <- c("before non-skip","before skip")#
#
# determine freq classes for plotting#
#BRE  <- c(-Inf, 10^seq(0,4,0.5), Inf)#
BRE  <- c(-Inf,10,100,1000,10000,Inf)#
a$f2C  <- cut(a$f2, breaks=BRE)#
levels(a$f2C)	<- c(1:(length(BRE)-1))#
a$f2C	<- as.numeric(as.character(a$f2C))#
#
# filter fixations#
nrow(a)#
a <- subset(a, fn1st!=0)        # find firstpass fixations#
nrow(a)#
a <- subset(a, wn!=1 & wn<nw-1) # remove fixations on first and last word per sentence#
nrow(a)#
a <- subset(a, firstlast==0)     # remove first & last fixation per sentence#
nrow(a)#
#
#
#i1st <- subset(a, FixNonWord==0)     # initial fixation case#
#s1st <- subset(a, SFC==1)            # single fixation case#
#x1st <- subset(a, SFC==1 & wn2>wn)   # SFC + forward-directed outgoing saccade#
x1st <- subset(a, SFC==1 & wn1==wn-1 & wn2>wn) # SFC + last word was fixated + forward-directed outgoing saccade#
sim   <- x1st#
nrow(sim)#
rm(a)#
#
#------------------------------------------------------------------------------------#
# load experimental data#
#------------------------------------------------------------------------------------#
ipath <- "/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/"#
ifile <- paste(corp,"_abc_iR1st.rda",sep="")#
#ifile <- "PSC275_abc_xB1st.rda" # -> additional: binocular criterium#
load(file=paste(ipath,corp,"_",samp,"/",ifile,sep=""))#
b$l2 <- 1/b$l2#
dat <- subset(b, wn1.x==wn-1 & wn2.x>wn)#
dat <- dat[, c("dur","s2","l2","f2") ]#
nrow(dat)#
#
rm(a,b,c)#
#
# define variables#
#skipping#
dat$s2F         <- factor(dat$s2)#
levels(dat$s2F) <- c("before non-skip","before skip")#
# freq classes#
#BRE  <- c(-Inf, 10^seq(0,4,0.5), Inf)#
BRE  <- c(-Inf,10,100,1000,10000,Inf)#
dat$f2C	<- cut(10^dat$f2, breaks=BRE)#
levels(dat$f2C)	<- c(1:(length(BRE)-1))#
dat$f2C	<- as.numeric(as.character(dat$f2C))#
#
#------------------------------------------------------------------------------------#
#### average per l, f, p of the next word#
#------------------------------------------------------------------------------------#
#
#----------------------------------------------------------------#
# 1) aggregate#
#----------------------------------------------------------------#
#
#length#
aml <- melt(sim, id=c("l2" ,"s2F"), measure=c("dur")) # a = SWIFT#
dml <- melt(dat, id=c("l2" ,"s2F"), measure=c("dur")) # d = Experiment#
aml <- subset(aml, l2<11)#
dml <- subset(dml, l2<11)#
asl <- data.frame(cast(aml, l2 + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsl <- data.frame(cast(dml, l2 + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asld<- data.frame(cast(aml, l2 ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsld<- data.frame(cast(dml, l2 ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asld$data <- "SWIFT 3" # "Simulation"#
dsld$data <- "Experiment"#
asld      <- rbind(asld, dsld)#
asld$Difference   <- asld$before.skip_mean - asld$before.non.skip_mean#
# check!! formula for non-paired t.test!!#
asld$se           <- sqrt((asld$before.skip_se^2 + asld$before.non.skip_se^2)/2)#
#
#freq#
amf <- melt(sim, id=c("f2C","s2F"), measure=c("dur"))#
dmf <- melt(dat, id=c("f2C","s2F"), measure=c("dur"))#
asf <- data.frame(cast(amf, f2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsf <- data.frame(cast(dmf, f2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asfd<- data.frame(cast(amf, f2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsfd<- data.frame(cast(dmf, f2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asfd$data <- "SWIFT 3"#
dsfd$data <- "Experiment"#
asfd      <- rbind(asfd, dsfd)#
asfd$Difference   <- asfd$before.skip_mean - asfd$before.non.skip_mean#
asfd$se           <- sqrt((asfd$before.skip_se^2 + asfd$before.non.skip_se^2)/2)#
#
#
#length#
sim <- subset(sim, l2<11)#
dat <- subset(dat, l2<11)#
sim$l2C	<- cut(sim$l2, b=c(0,6.5,8.5,22))#
levels(sim$l2C)	<- c("Short Words\n[2-6 let]","Middle Length\n[7-8]","Long Words\n[8-10 let]")#
dat$l2C	<- cut(dat$l2, b=c(0,6.5,8.5,22))#
levels(dat$l2C)	<- c("Short Words\n[2-6 let]","Middle Length\n[7-8]","Long Words\n[8-10 let]")#
amlC <- melt(sim, id=c("l2C" ,"s2F"), measure=c("dur")) # a = SWIFT#
dmlC <- melt(dat, id=c("l2C" ,"s2F"), measure=c("dur")) # d = Experiment#
aslC <- data.frame(cast(amlC, l2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dslC <- data.frame(cast(dmlC, l2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asldC<- data.frame(cast(amlC, l2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsldC<- data.frame(cast(dmlC, l2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asldC$data <- "SWIFT 3"#
dsldC$data <- "Experiment"#
asldC      <- rbind(asldC, dsldC)#
asldC$Difference   <- asldC$before.skip_mean - asldC$before.non.skip_mean#
# check!! formula for non-paired t.test!!#
asldC$se           <- sqrt((asldC$before.skip_se^2 + asldC$before.non.skip_se^2)/2)#
#
#
#
if (corp=="SHUF")	corp1	<- "Shuffled Text"#
if (corp=="PSC275")	corp1	<- "Normal Text"#
asf$corp <- dsf$corp <- asl$corp <- dsl$corp <- asfd$corp <- asld$corp <- corp1#
aslC$corp <- dslC$corp <- asldC$corp	<- corp1#
#
ASF[[ic]] <- asf#
DSF[[ic]] <- dsf#
ASL[[ic]] <- asl#
DSL[[ic]] <- dsl#
#
ASLD[[ic]] <- asld#
ASFD[[ic]] <- asfd#
#
#
ASLc[[ic]] <- aslC#
DSLc[[ic]] <- dslC#
ASLDc[[ic]] <- asldC#
#
} # for (ic in 1:length(corp)) {#
#
#
rm(asf,dsf,  asl,dsl,  asld,asfd,   aslC,dslC,asldC)#
asf  <- ASF[[1]]#
dsf  <- DSF[[1]]#
asl  <- ASL[[1]]#
dsl  <- DSL[[1]]#
asfd <- ASFD[[1]]#
asld <- ASLD[[1]]#
aslC <- ASLc[[1]]#
dslC <- DSLc[[1]]#
asldC<- ASLDc[[1]]#
if (length(CORP)>1) for (i in 2:length(CORP)) {#
  asf <- rbind(asf, ASF[[i]])#
  dsf <- rbind(dsf, DSF[[i]])#
  asl <- rbind(asl, ASL[[i]])#
  dsl <- rbind(dsl, DSL[[i]])#
#
  asfd <- rbind(asfd, ASFD[[i]])#
  asld <- rbind(asld, ASLD[[i]])#
#
  aslC <- rbind(aslC, ASLc[[i]])#
  dslC <- rbind(dslC, DSLc[[i]])#
  asldC<- rbind(asldC, ASLDc[[i]])#
}#
#
skipLabel	<- c("non-skip","before-skip")#
levels(asl$s2F)	<- skipLabel#
levels(asf$s2F)	<- skipLabel#
levels(dsl$s2F)	<- skipLabel#
levels(dsf$s2F)	<- skipLabel#
#
levels(aslC$s2F)	<- skipLabel#
levels(dslC$s2F)	<- skipLabel#
#
#
asl$corp	<- factor(asl$corp)#
asf$corp	<- factor(asf$corp)#
dsl$corp	<- factor(dsl$corp)#
dsf$corp	<- factor(dsf$corp)#
asld$corp	<- factor(asld$corp)#
asfd$corp	<- factor(asfd$corp)#
#
aslC$corp	<- factor(aslC$corp)#
dslC$corp	<- factor(dslC$corp)#
asldC$corp	<- factor(asldC$corp)#
#
asl$corp	<- factor(asl$corp, levels=levels(asl$corp)[c(2,1)])#
asf$corp	<- factor(asf$corp, levels=levels(asf$corp)[c(2,1)])#
dsl$corp	<- factor(dsl$corp, levels=levels(dsl$corp)[c(2,1)])#
dsf$corp	<- factor(dsf$corp, levels=levels(dsf$corp)[c(2,1)])#
#
asld$corp	<- factor(asld$corp, levels=levels(asld$corp)[c(2,1)])#
asfd$corp	<- factor(asfd$corp, levels=levels(asfd$corp)[c(2,1)])#
#
aslC$corp	<- factor(aslC$corp , levels=levels(aslC$corp )[c(2,1)])#
dslC$corp	<- factor(dslC$corp , levels=levels(dslC$corp )[c(2,1)])#
asldC$corp	<- factor(asldC$corp, levels=levels(asldC$corp)[c(2,1)])#
#
#
print("aggregate & plotting ...")#
#----------------------------------------------------------------#
# 2) plot#
#----------------------------------------------------------------#
#----------------------------------------------------------------#
# 2b) Schwarz - Weiß#
#----------------------------------------------------------------#
ymin  <- floor(   min(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ymax  <- ceiling( max(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ybre  <- seq(ymin, ymax, by=20)#
asl$data	<- "Simulation"#
dsl$data	<- "Experiment"#
sl			<- rbind(asl, dsl)#
sl$data		<- factor(sl$data)#
# Experiment#
p.dnl <- qplot(x=l2, y=dur_mean, data=subset(dsl,corp=="Normal Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Experiment")+#
    scale_colour_manual(  name="", values="grey", legend=FALSE)+#
    scale_shape_manual(   name="", values=c(2,3))+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position=c(1.1,0.02))#
p.dsl <- qplot(x=l2, y=dur_mean, data=subset(dsl,corp=="Shuffled Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Experiment")+#
    scale_colour_manual(  name="", values="grey", legend=FALSE)+#
    scale_shape_manual(   name="", values=c(2,3))+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
#
# Simulation#
p.anl <- qplot(x=l2, y=dur_mean, data=subset(asl,corp=="Normal Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Simulation")+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(2,3), legend=FALSE)+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
p.asl <- qplot(x=l2, y=dur_mean, data=subset(asl,corp=="Shuffled Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Simulation")+#
    scale_colour_manual(  name="", values="black", legend=FALSE)+#
    scale_shape_manual(   name="", values=c(2,3))+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
#
#
ymind  <- floor(   min(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
ymaxd  <- ceiling( max(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
#ymax  <- ymax + 20#
ybred  <- seq(ymind, ymaxd, by=25)#
asld$data	<- factor(asld$data)#
p.dnld <- qplot(x=l2, y=Difference, data=subset(asld,corp=="Normal Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	colour=data, width=0.3,#
	main="       (Skip) -- (Non-Skip)")+#
	scale_colour_manual(  name="", values=c("grey","black"))+#
	scale_x_continuous(name="         Word Length [let]")+#
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(0.1,0.02))#
p.dsld <- qplot(x=l2, y=Difference, data=subset(asld,corp=="Shuffled Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	colour=data, width=0.3, #
	main="       (Skip) -- (Non-Skip)") + #
	scale_colour_manual(    name="", values=c("grey","black"), legend=FALSE) +#
	scale_linetype_manual(name="", values=c(4,2))+#
	scale_x_continuous(name="         Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position="none")#
#
levels(asldC$corp)	<- c("Shuffled","Normal")#
levels(asldC$l2C)	<- c("short [2-6]","Middle Length\n[7-8]","long [9-10]")#
#dev.off()#
quartz(width=3.5,height=3)#
print(  p.sub <- qplot(x=corp, y=Difference, fill=data, facets=.~l2C,#
	xlab="      ", ylab="", ymin=Difference-se, ymax=Difference+se,#
	data=subset(asldC,l2C!="Middle Length\n[7-8]"), geom=c("bar","errorbar"), position="dodge") + #
	geom_hline(yintercept=0) + scale_fill_grey(name="") + theme_bw() + #
	opts(legend.position=c(0.35,0.8))   )#c(0.7,1.1)#
ggsave(paste("skipsimple2mLc_SW_bar_",samp,".eps",sep=""))#
#
dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(100, 100)))#
#
grid.text("Normal Text"  , 0.99, 0.75, gp=gpar(fontsize=14), rot=270)#
grid.text("Shuffled Text", 0.99, 0.25, gp=gpar(fontsize=14), rot=270)#
#
#
print(p.dnl , vp = viewport(layout.pos.row =  1: 50, layout.pos.col =  1: 33))#
print(p.anl , vp = viewport(layout.pos.row =  1: 50, layout.pos.col = 33: 65))#
print(p.dnld, vp = viewport(layout.pos.row =  1: 50, layout.pos.col = 65: 98))#
#
print(p.dsl , vp = viewport(layout.pos.row = 51:100, layout.pos.col =  1: 33))#
print(p.asl , vp = viewport(layout.pos.row = 51:100, layout.pos.col = 33: 65))#
print(p.dsld, vp = viewport(layout.pos.row = 51:100, layout.pos.col = 65: 98))#
#
#print(p.sub, vp = viewport(layout.pos.row = 55:82, layout.pos.col = 72:98))#
#
#
dev.copy2eps(file=paste("skipsimple2mLc_SW_",samp,"c.eps",sep=""))#
#
#
#
#--------------------#
# use facet_grid()#
#--------------------#
asld$corp	<- factor(asld$corp, levels=levels(asld$corp)[2:1])#
# combine data#
pdat	<- rbind(asl, dsl)#
pdat$corp	<- factor(pdat$corp, levels=levels(pdat$corp)[2:1])#
pdat$s2F	<- factor(pdat$s2F)#
pdat$corp	<- factor(pdat$corp)#
pdat$max	<- pdat$dur_mean + pdat$dur_se#
pdat$min	<- pdat$dur_mean - pdat$dur_se#
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), #"errorbar",#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
#	ymin=min, ymax=max,#
    shape=s2F, linetype=data) +facet_grid(corp~data) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.3,0.85)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~main2) + # #
    scale_linetype( name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
pRight
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~.) + # #
    scale_linetype( name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data)
#
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data)+facet_grid(corp~data)
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data)+facet_grid(corp~.)
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data)+facet_grid(.~data)
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data)+facet_grid(corp~.)
pdat
pdat$data	<- factor(pdat$data)
pdat$data	<- factor(pdat$data)#
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data)+facet_grid(corp~.)
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data)+facet_grid(corp~data)
head(pdat)
summary(pdat)
table(pdat$data, pdat$corp)
pdat	<- rbind(pdat[1,], pdat)
pdat
tmp	<- pdat[1,]
tmp
tmp$s2F	<- "before-skip"
tmp
pdat[1,]<- tmp
pdat
pdat[1,]
tmp$s2F	<- "before-skip"#
tmp$l2	<- 10#
tmp$data<- "Experiment"
tmp
pdat[1,]<- tmp
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data)+facet_grid(corp~data)
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data)+facet_grid(corp~.)
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se, colour=data,#
    shape=s2F, linetype=data)+facet_grid(corp~.)
qplot(l2, dur_mean, data=subset(pdat,l2<=9), geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se, colour=data,#
    shape=s2F, linetype=data)+facet_grid(corp~.)
qplot(l2, dur_mean, data=subset(pdat,l2<=9), geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se, colour=data,#
    shape=s2F, linetype=data)+facet_grid(corp~data)
qplot(l2, dur_mean, data=subset(pdat,l2<=4), geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se, colour=data,#
    shape=s2F, linetype=data)+facet_grid(corp~data)
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se, colour=data,#
    shape=s2F, linetype=data)+facet_grid(corp~.)
#
pdat	<- rbind(asl, dsl)#
pdat$corp	<- factor(pdat$corp, levels=levels(pdat$corp)[2:1])#
pdat$s2F	<- factor(pdat$s2F)#
pdat$corp	<- factor(pdat$corp)#
pdat$max	<- pdat$dur_mean + pdat$dur_se#
pdat$min	<- pdat$dur_mean - pdat$dur_se
pdat <- subset(pdat, l2<8)
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se, colour=data,#
    shape=s2F, linetype=data)+facet_grid(corp~data)
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se, colour=data,#
    shape=s2F, linetype=data)+facet_grid(corp~.)
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se, colour=data,#
    shape=s2F, linetype=data)+facet_grid(corp~s2F)
str(pdat$data)
pdat$dat2	<- pdat$data#
qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"),#
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se, colour=data,#
    shape=s2F, linetype=data)+facet_grid(corp~dat2)
#
pdat	<- rbind(asl, dsl)#
pdat$corp	<- factor(pdat$corp, levels=levels(pdat$corp)[2:1])#
pdat$s2F	<- factor(pdat$s2F)#
pdat$corp	<- factor(pdat$corp)#
pdat$max	<- pdat$dur_mean + pdat$dur_se#
pdat$min	<- pdat$dur_mean - pdat$dur_se#
pdat$dat2	<- pdat$data#
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("errorbar","line","point"), ##
	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data) +facet_grid(corp~dat2) + # , width=0.3#
#    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.3,0.85)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~.) + # #
    scale_linetype( name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
#
dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
quartz(width=9*0.95, height=6*0.95)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), ##
#	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data) +facet_grid(corp~dat2) + # , width=0.3#
    geom_errorbar(aes(ymin=dur_min, ymax=dur_max))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.3,0.85)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~.) + # #
    scale_linetype( name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
#
dev.off()#
quartz(width=9*0.95, height=6*0.95)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), ##
#	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data) +facet_grid(corp~dat2) + # , width=0.3#
    geom_errorbar(aes(ymin= dur_mean - dur_se, ymax= dur_mean + dur_se))+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.3,0.85)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~.) + # #
    scale_linetype( name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
#
dev.off()#
quartz(width=9*0.95, height=6*0.95)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), ##
#	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data) +facet_grid(corp~dat2) + # #
    geom_errorbar(aes(ymin= dur_mean - dur_se, ymax= dur_mean + dur_se), linetype=1, width=0.3)+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.3,0.85)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~.) + # #
    scale_linetype( name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
#
dev.off()#
quartz(width=9*0.95, height=6*0.95)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
rm(list=l())
rm(list=ls())
#
SIM  	<- read.table("../sim.vers")[[1]]#
#SIM	<- "14a_newgoffid"#
#
CORP	<- c("SHUF","PSC275")  # c("SHUF","PSC275","PSC30")#
samp 	<- 0#
#
#
print(paste("sim-Version: ",SIM,sep=""))#
#
ASF  	<- DSF  <- ASL  <- DSL  <- ASLD  <- ASFD  <- list()#
ASLc	<- DSLc	<- ASLDc	<- list()#
for (ic in c(1:length(CORP)) ) {#
#
corp 	<- CORP[ic]#
print(paste("process ",corp," ...",sep=""))#
#
#------------------------------------------------------------------------------------#
# load simulated data#
#------------------------------------------------------------------------------------#
ifile1    <- paste("../",SIM,corp,"/seq.dat",sep="")#
incol	   <- c("id","sn","wn","let","dur","st1","ao1","l","f","p","firstlast","fn1st","SFC","FixNonWord","nFixOnWord","testreg","x12")#
a	       <- read.table(ifile1, sep="	", col.names=incol, na.strings="-999")#
# firstlast = codes first and last fixation in a sentence. 1 = first, 2 = last, 0 = all others#
# st1 (alternative: n_skp_wrds) = saccade type of the previous saccade (1 = forward, 0 = refixation, 2 = skipping, -1 = regression to last word, ..)#
# fn1st = fixation number in first pass; 1 = first fixation on the word in firstpass reading; 2 = second fixation on the word in firstpass reading; 0 = more-pass reading fixation#
# SFC = Anzahl der Fixationen auf dem Wort im firstpass. 1 = single fixation case, 2 = 2-fixation case#
# FixNonWord = Fixation Nr. n auf dem fixierten Wort (1. Fixation = 0)#
# nFixOnWord = Anzahl der Fixationen auf dem fixierten Wort wÃ¤hrend des Lesens dieses Satzes (1 Fixation = 0; bis ...)#
#
#
#------------------------------------------------------------------------------------#
# add corpus info: nw, l2, f2, p2#
#------------------------------------------------------------------------------------#
ifile2    <- paste("../",SIM,corp,"/freq.dat",sep="")#
exp       <- read.table(ifile2)#
depvars   <- c("d1","d2","d0","trt", "p0","p2","p3","rgc")#
if (dim(exp)[2]==18) agg <- "pW"#
if (dim(exp)[2]==19) agg <- "pSW"#
if (agg=="pW" ) ivars <- c("sd1", "sd2", "sd0", "strt")#
if (agg=="pSW") ivars <- c("id",  "sn" , "wn" , "PSCsn","PSCwn")#
names(exp)	<- c("sn","wn","l","f","p", depvars, ivars, "nw")#
if (agg=="pW" ) exp <- exp[, !names(exp)%in%ivars ]#
word      <- exp[, !names(exp)%in%depvars]#
exp       <- exp[,  names(exp)%in%depvars]#
word[, c("l2","f2","p2")] <- rbind( word[2:nrow(word), c("l","f","p")], c(NA,NA,NA)  )#
word[word$wn==word$nw, c("l2","f2","p2")] <- c(NA, NA, NA)#
#match corpus info to data#
if (agg=="pW" ) did       <-                     a$sn*100 +    a$wn#
if (agg=="pW" ) cid       <-                  word$sn*100 + word$wn#
if (agg=="pSW") did       <-    a$id*100000 +    a$sn*100 +    a$wn # valid for id <= 999#
if (agg=="pSW") cid       <- word$id*100000 + word$sn*100 + word$wn#
idx_isw   <- match(did, cid)#
cvars     <- c("nw","l2","f2","p2")#
a[,cvars] <- word[idx_isw,cvars]#
#------------------------------------------------------------------------------------#
#
#------------------------------------------------------------------------------------#
# data processing: define variables + data selection#
#------------------------------------------------------------------------------------#
# find fixations before skip & before non-skip#
a$wn2     <- c( a$wn[2:nrow(a)], NA )#
a$wn2[a$firstlast==2] <- NA#
a$wn1     <- c( NA, a$wn[1:(nrow(a)-1)] )#
a$wn1[a$firstlast==1] <- NA#
#
a$s2      <- ifelse( a$wn2 > a$wn+1, 1, 0 )#
a$s2F     <- factor(a$s2)#
levels(a$s2F) <- c("before non-skip","before skip")#
#
# determine freq classes for plotting#
#BRE  <- c(-Inf, 10^seq(0,4,0.5), Inf)#
BRE  <- c(-Inf,10,100,1000,10000,Inf)#
a$f2C  <- cut(a$f2, breaks=BRE)#
levels(a$f2C)	<- c(1:(length(BRE)-1))#
a$f2C	<- as.numeric(as.character(a$f2C))#
#
# filter fixations#
nrow(a)#
a <- subset(a, fn1st!=0)        # find firstpass fixations#
nrow(a)#
a <- subset(a, wn!=1 & wn<nw-1) # remove fixations on first and last word per sentence#
nrow(a)#
a <- subset(a, firstlast==0)     # remove first & last fixation per sentence#
nrow(a)#
#
#
#i1st <- subset(a, FixNonWord==0)     # initial fixation case#
#s1st <- subset(a, SFC==1)            # single fixation case#
#x1st <- subset(a, SFC==1 & wn2>wn)   # SFC + forward-directed outgoing saccade#
x1st <- subset(a, SFC==1 & wn1==wn-1 & wn2>wn) # SFC + last word was fixated + forward-directed outgoing saccade#
sim   <- x1st#
nrow(sim)#
rm(a)#
#
#------------------------------------------------------------------------------------#
# load experimental data#
#------------------------------------------------------------------------------------#
ipath <- "/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/"#
ifile <- paste(corp,"_abc_iR1st.rda",sep="")#
#ifile <- "PSC275_abc_xB1st.rda" # -> additional: binocular criterium#
load(file=paste(ipath,corp,"_",samp,"/",ifile,sep=""))#
b$l2 <- 1/b$l2#
dat <- subset(b, wn1.x==wn-1 & wn2.x>wn)#
dat <- dat[, c("dur","s2","l2","f2") ]#
nrow(dat)#
#
rm(a,b,c)#
#
# define variables#
#skipping#
dat$s2F         <- factor(dat$s2)#
levels(dat$s2F) <- c("before non-skip","before skip")#
# freq classes#
#BRE  <- c(-Inf, 10^seq(0,4,0.5), Inf)#
BRE  <- c(-Inf,10,100,1000,10000,Inf)#
dat$f2C	<- cut(10^dat$f2, breaks=BRE)#
levels(dat$f2C)	<- c(1:(length(BRE)-1))#
dat$f2C	<- as.numeric(as.character(dat$f2C))#
#
#------------------------------------------------------------------------------------#
#### average per l, f, p of the next word#
#------------------------------------------------------------------------------------#
#
#----------------------------------------------------------------#
# 1) aggregate#
#----------------------------------------------------------------#
#
#length#
aml <- melt(sim, id=c("l2" ,"s2F"), measure=c("dur")) # a = SWIFT#
dml <- melt(dat, id=c("l2" ,"s2F"), measure=c("dur")) # d = Experiment#
aml <- subset(aml, l2<11)#
dml <- subset(dml, l2<11)#
asl <- data.frame(cast(aml, l2 + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsl <- data.frame(cast(dml, l2 + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asld<- data.frame(cast(aml, l2 ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsld<- data.frame(cast(dml, l2 ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asld$data <- "SWIFT 3" # "Simulation"#
dsld$data <- "Experiment"#
asld      <- rbind(asld, dsld)#
asld$Difference   <- asld$before.skip_mean - asld$before.non.skip_mean#
# check!! formula for non-paired t.test!!#
asld$se           <- sqrt((asld$before.skip_se^2 + asld$before.non.skip_se^2)/2)#
#
#freq#
amf <- melt(sim, id=c("f2C","s2F"), measure=c("dur"))#
dmf <- melt(dat, id=c("f2C","s2F"), measure=c("dur"))#
asf <- data.frame(cast(amf, f2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsf <- data.frame(cast(dmf, f2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asfd<- data.frame(cast(amf, f2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsfd<- data.frame(cast(dmf, f2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asfd$data <- "SWIFT 3"#
dsfd$data <- "Experiment"#
asfd      <- rbind(asfd, dsfd)#
asfd$Difference   <- asfd$before.skip_mean - asfd$before.non.skip_mean#
asfd$se           <- sqrt((asfd$before.skip_se^2 + asfd$before.non.skip_se^2)/2)#
#
#
#length#
sim <- subset(sim, l2<11)#
dat <- subset(dat, l2<11)#
sim$l2C	<- cut(sim$l2, b=c(0,6.5,8.5,22))#
levels(sim$l2C)	<- c("Short Words\n[2-6 let]","Middle Length\n[7-8]","Long Words\n[8-10 let]")#
dat$l2C	<- cut(dat$l2, b=c(0,6.5,8.5,22))#
levels(dat$l2C)	<- c("Short Words\n[2-6 let]","Middle Length\n[7-8]","Long Words\n[8-10 let]")#
amlC <- melt(sim, id=c("l2C" ,"s2F"), measure=c("dur")) # a = SWIFT#
dmlC <- melt(dat, id=c("l2C" ,"s2F"), measure=c("dur")) # d = Experiment#
aslC <- data.frame(cast(amlC, l2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dslC <- data.frame(cast(dmlC, l2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asldC<- data.frame(cast(amlC, l2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsldC<- data.frame(cast(dmlC, l2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asldC$data <- "SWIFT 3"#
dsldC$data <- "Experiment"#
asldC      <- rbind(asldC, dsldC)#
asldC$Difference   <- asldC$before.skip_mean - asldC$before.non.skip_mean#
# check!! formula for non-paired t.test!!#
asldC$se           <- sqrt((asldC$before.skip_se^2 + asldC$before.non.skip_se^2)/2)#
#
#
#
if (corp=="SHUF")	corp1	<- "Shuffled Text"#
if (corp=="PSC275")	corp1	<- "Normal Text"#
asf$corp <- dsf$corp <- asl$corp <- dsl$corp <- asfd$corp <- asld$corp <- corp1#
aslC$corp <- dslC$corp <- asldC$corp	<- corp1#
#
ASF[[ic]] <- asf#
DSF[[ic]] <- dsf#
ASL[[ic]] <- asl#
DSL[[ic]] <- dsl#
#
ASLD[[ic]] <- asld#
ASFD[[ic]] <- asfd#
#
#
ASLc[[ic]] <- aslC#
DSLc[[ic]] <- dslC#
ASLDc[[ic]] <- asldC#
#
} # for (ic in 1:length(corp)) {#
#
#
rm(asf,dsf,  asl,dsl,  asld,asfd,   aslC,dslC,asldC)#
asf  <- ASF[[1]]#
dsf  <- DSF[[1]]#
asl  <- ASL[[1]]#
dsl  <- DSL[[1]]#
asfd <- ASFD[[1]]#
asld <- ASLD[[1]]#
aslC <- ASLc[[1]]#
dslC <- DSLc[[1]]#
asldC<- ASLDc[[1]]#
if (length(CORP)>1) for (i in 2:length(CORP)) {#
  asf <- rbind(asf, ASF[[i]])#
  dsf <- rbind(dsf, DSF[[i]])#
  asl <- rbind(asl, ASL[[i]])#
  dsl <- rbind(dsl, DSL[[i]])#
#
  asfd <- rbind(asfd, ASFD[[i]])#
  asld <- rbind(asld, ASLD[[i]])#
#
  aslC <- rbind(aslC, ASLc[[i]])#
  dslC <- rbind(dslC, DSLc[[i]])#
  asldC<- rbind(asldC, ASLDc[[i]])#
}#
#
skipLabel	<- c("non-skip","before-skip")#
levels(asl$s2F)	<- skipLabel#
levels(asf$s2F)	<- skipLabel#
levels(dsl$s2F)	<- skipLabel#
levels(dsf$s2F)	<- skipLabel#
#
levels(aslC$s2F)	<- skipLabel#
levels(dslC$s2F)	<- skipLabel#
#
#
asl$corp	<- factor(asl$corp)#
asf$corp	<- factor(asf$corp)#
dsl$corp	<- factor(dsl$corp)#
dsf$corp	<- factor(dsf$corp)#
asld$corp	<- factor(asld$corp)#
asfd$corp	<- factor(asfd$corp)#
#
aslC$corp	<- factor(aslC$corp)#
dslC$corp	<- factor(dslC$corp)#
asldC$corp	<- factor(asldC$corp)#
#
asl$corp	<- factor(asl$corp, levels=levels(asl$corp)[c(2,1)])#
asf$corp	<- factor(asf$corp, levels=levels(asf$corp)[c(2,1)])#
dsl$corp	<- factor(dsl$corp, levels=levels(dsl$corp)[c(2,1)])#
dsf$corp	<- factor(dsf$corp, levels=levels(dsf$corp)[c(2,1)])#
#
asld$corp	<- factor(asld$corp, levels=levels(asld$corp)[c(2,1)])#
asfd$corp	<- factor(asfd$corp, levels=levels(asfd$corp)[c(2,1)])#
#
aslC$corp	<- factor(aslC$corp , levels=levels(aslC$corp )[c(2,1)])#
dslC$corp	<- factor(dslC$corp , levels=levels(dslC$corp )[c(2,1)])#
asldC$corp	<- factor(asldC$corp, levels=levels(asldC$corp)[c(2,1)])#
#
#
print("aggregate & plotting ...")#
#----------------------------------------------------------------#
# 2) plot#
#----------------------------------------------------------------#
#----------------------------------------------------------------#
# 2b) Schwarz - Weiß#
#----------------------------------------------------------------#
ymin  <- floor(   min(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ymax  <- ceiling( max(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ybre  <- seq(ymin, ymax, by=20)#
asl$data	<- "SWIFT 3" #"Simulation"#
dsl$data	<- "Experiment"#
sl			<- rbind(asl, dsl)#
sl$data		<- factor(sl$data)#
# Experiment#
p.dnl <- qplot(x=l2, y=dur_mean, data=subset(dsl,corp=="Normal Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Experiment")+#
    scale_colour_manual(  name="", values="grey", legend=FALSE)+#
    scale_shape_manual(   name="", values=c(2,3))+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position=c(1.1,0.02))#
p.dsl <- qplot(x=l2, y=dur_mean, data=subset(dsl,corp=="Shuffled Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Experiment")+#
    scale_colour_manual(  name="", values="grey", legend=FALSE)+#
    scale_shape_manual(   name="", values=c(2,3))+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
#
# Simulation#
p.anl <- qplot(x=l2, y=dur_mean, data=subset(asl,corp=="Normal Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Simulation")+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(2,3), legend=FALSE)+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
p.asl <- qplot(x=l2, y=dur_mean, data=subset(asl,corp=="Shuffled Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Simulation")+#
    scale_colour_manual(  name="", values="black", legend=FALSE)+#
    scale_shape_manual(   name="", values=c(2,3))+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
#
#
ymind  <- floor(   min(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
ymaxd  <- ceiling( max(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
#ymax  <- ymax + 20#
ybred  <- seq(ymind, ymaxd, by=25)#
asld$data	<- factor(asld$data)#
p.dnld <- qplot(x=l2, y=Difference, data=subset(asld,corp=="Normal Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	colour=data, width=0.3,#
	main="       (Skip) -- (Non-Skip)")+#
	scale_colour_manual(  name="", values=c("grey","black"))+#
	scale_x_continuous(name="         Word Length [let]")+#
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(0.1,0.02))#
p.dsld <- qplot(x=l2, y=Difference, data=subset(asld,corp=="Shuffled Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	colour=data, width=0.3, #
	main="       (Skip) -- (Non-Skip)") + #
	scale_colour_manual(    name="", values=c("grey","black"), legend=FALSE) +#
	scale_linetype_manual(name="", values=c(4,2))+#
	scale_x_continuous(name="         Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position="none")#
#
levels(asldC$corp)	<- c("Shuffled","Normal")#
levels(asldC$l2C)	<- c("short [2-6]","Middle Length\n[7-8]","long [9-10]")#
#dev.off()#
quartz(width=3.5,height=3)#
print(  p.sub <- qplot(x=corp, y=Difference, fill=data, facets=.~l2C,#
	xlab="      ", ylab="", ymin=Difference-se, ymax=Difference+se,#
	data=subset(asldC,l2C!="Middle Length\n[7-8]"), geom=c("bar","errorbar"), position="dodge") + #
	geom_hline(yintercept=0) + scale_fill_grey(name="") + theme_bw() + #
	opts(legend.position=c(0.35,0.8))   )#c(0.7,1.1)#
ggsave(paste("skipsimple2mLc_SW_bar_",samp,".eps",sep=""))#
#
dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(100, 100)))#
#
grid.text("Normal Text"  , 0.99, 0.75, gp=gpar(fontsize=14), rot=270)#
grid.text("Shuffled Text", 0.99, 0.25, gp=gpar(fontsize=14), rot=270)#
#
#
print(p.dnl , vp = viewport(layout.pos.row =  1: 50, layout.pos.col =  1: 33))#
print(p.anl , vp = viewport(layout.pos.row =  1: 50, layout.pos.col = 33: 65))#
print(p.dnld, vp = viewport(layout.pos.row =  1: 50, layout.pos.col = 65: 98))#
#
print(p.dsl , vp = viewport(layout.pos.row = 51:100, layout.pos.col =  1: 33))#
print(p.asl , vp = viewport(layout.pos.row = 51:100, layout.pos.col = 33: 65))#
print(p.dsld, vp = viewport(layout.pos.row = 51:100, layout.pos.col = 65: 98))#
#
#print(p.sub, vp = viewport(layout.pos.row = 55:82, layout.pos.col = 72:98))#
#
#
dev.copy2eps(file=paste("skipsimple2mLc_SW_",samp,"c.eps",sep=""))#
#
#
#
#--------------------#
# use facet_grid()#
#--------------------#
asld$corp	<- factor(asld$corp, levels=levels(asld$corp)[2:1])#
# combine data#
pdat	<- rbind(asl, dsl)#
pdat$corp	<- factor(pdat$corp, levels=levels(pdat$corp)[2:1])#
pdat$s2F	<- factor(pdat$s2F)#
pdat$corp	<- factor(pdat$corp)#
pdat$max	<- pdat$dur_mean + pdat$dur_se#
pdat$min	<- pdat$dur_mean - pdat$dur_se#
pdat$dat2	<- pdat$data#
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), ##
#	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data) +facet_grid(corp~dat2) + # #
    geom_errorbar(aes(ymin= dur_mean - dur_se, ymax= dur_mean + dur_se), linetype=1, width=0.3)+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.3,0.85)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data, width=0.3) + facet_grid(corp~.) + # #
    scale_linetype( name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
#
dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), ##
#	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data) +facet_grid(corp~dat2) + # #
    geom_errorbar(aes(ymin= dur_mean - dur_se, ymax= dur_mean + dur_se), linetype=1, width=0.3)+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.3,0.85)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("line","point"),#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data) + facet_grid(corp~.) + # #
    geom_errorbar(aes(ymin=Difference-se, ymax=Difference+se),width=0.3, linetype=1)+#
    scale_linetype( name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
#
dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 60))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 61:100))
source("xskipsimple2mLc.R")
source("xskipsimple2mLc.R")
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 66))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 67:100))
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 62))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 63:100))
source("xskipsimple2mLc.R")
source("xskipsimple2mL_delta1.R")
source("xskipsimple2mL_delta1.R")
source("xskipsimple2mL_delta1.R")
source("xskipsimple2mL_delta1.R")
#
#
p.dnld <- qplot(x=l2, y=Difference, data=subset(asld,corp=="Normal Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=data, colour=corp, width=0.3,#
	main="       (Skip) -- (Non-Skip)")+#
	scale_colour_grey(name="", legend=FALSE)+#
	scale_linetype_manual(name="", values=c(2,1), legend=FALSE)+#
	scale_x_continuous(name="         Word Length [let]")+#
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(0.40,0.78))#
p.dsld <- qplot(x=l2, y=Difference, data=subset(asld,corp!="Normal Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=data, colour=corp, width=0.3, #
	main="       (Skip) -- (Non-Skip)") + #
	scale_colour_grey(name="") + #
	scale_linetype_manual(name="", values=c(2,1))+#
	scale_x_continuous(name="         Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()#
quartz(width=8, height=3)#
pushViewport(viewport(layout = grid.layout(100, 100)))#
print(p.dnld, vp = viewport(layout.pos.row =  1:100, layout.pos.col =  1: 38))#
print(p.dsld, vp = viewport(layout.pos.row =  1:100, layout.pos.col = 39: 92))#
dev.copy2eps(file=paste("skipsimple2mLd_SW_",samp,"_delta.eps",sep=""))
#
SIM  	<- read.table("../sim.vers")[[1]]#
#SIM	<- "14a_newgoffid"#
#
CORP	<- c("SHUFb_reducedDelta1","SHUF","PSC275")  # c("SHUF","PSC275","PSC30")#
samp 	<- 0#
#
print(paste("sim-Version: ",SIM,sep=""))#
#
ASF  	<- DSF  <- ASL  <- DSL  <- ASLD  <- ASFD  <- list()#
ASLc	<- DSLc	<- ASLDc	<- list()#
for (ic in c(1:length(CORP)) ) {#
#
corp 	<- CORP[ic]#
print(paste("process ",corp," ...",sep=""))#
#
#------------------------------------------------------------------------------------#
# load simulated data#
#------------------------------------------------------------------------------------#
ifile1    <- paste("../",SIM,corp,"/seq.dat",sep="")#
incol	   <- c("id","sn","wn","let","dur","st1","ao1","l","f","p","firstlast","fn1st","SFC","FixNonWord","nFixOnWord","testreg","x12")#
a	       <- read.table(ifile1, sep="	", col.names=incol, na.strings="-999")#
# firstlast = codes first and last fixation in a sentence. 1 = first, 2 = last, 0 = all others#
# st1 (alternative: n_skp_wrds) = saccade type of the previous saccade (1 = forward, 0 = refixation, 2 = skipping, -1 = regression to last word, ..)#
# fn1st = fixation number in first pass; 1 = first fixation on the word in firstpass reading; 2 = second fixation on the word in firstpass reading; 0 = more-pass reading fixation#
# SFC = Anzahl der Fixationen auf dem Wort im firstpass. 1 = single fixation case, 2 = 2-fixation case#
# FixNonWord = Fixation Nr. n auf dem fixierten Wort (1. Fixation = 0)#
# nFixOnWord = Anzahl der Fixationen auf dem fixierten Wort wÃ¤hrend des Lesens dieses Satzes (1 Fixation = 0; bis ...)#
#
#
#------------------------------------------------------------------------------------#
# add corpus info: nw, l2, f2, p2#
#------------------------------------------------------------------------------------#
ifile2    <- paste("../",SIM,corp,"/freq.dat",sep="")#
exp       <- read.table(ifile2)#
depvars   <- c("d1","d2","d0","trt", "p0","p2","p3","rgc")#
if (dim(exp)[2]==18) agg <- "pW"#
if (dim(exp)[2]==19) agg <- "pSW"#
if (agg=="pW" ) ivars <- c("sd1", "sd2", "sd0", "strt")#
if (agg=="pSW") ivars <- c("id",  "sn" , "wn" , "PSCsn","PSCwn")#
names(exp)	<- c("sn","wn","l","f","p", depvars, ivars, "nw")#
if (agg=="pW" ) exp <- exp[, !names(exp)%in%ivars ]#
word      <- exp[, !names(exp)%in%depvars]#
exp       <- exp[,  names(exp)%in%depvars]#
word[, c("l2","f2","p2")] <- rbind( word[2:nrow(word), c("l","f","p")], c(NA,NA,NA)  )#
word[word$wn==word$nw, c("l2","f2","p2")] <- c(NA, NA, NA)#
#match corpus info to data#
if (agg=="pW" ) did       <-                     a$sn*100 +    a$wn#
if (agg=="pW" ) cid       <-                  word$sn*100 + word$wn#
if (agg=="pSW") did       <-    a$id*100000 +    a$sn*100 +    a$wn # valid for id <= 999#
if (agg=="pSW") cid       <- word$id*100000 + word$sn*100 + word$wn#
idx_isw   <- match(did, cid)#
cvars     <- c("nw","l2","f2","p2")#
a[,cvars] <- word[idx_isw,cvars]#
#------------------------------------------------------------------------------------#
#
#------------------------------------------------------------------------------------#
# data processing: define variables + data selection#
#------------------------------------------------------------------------------------#
# find fixations before skip & before non-skip#
a$wn2     <- c( a$wn[2:nrow(a)], NA )#
a$wn2[a$firstlast==2] <- NA#
a$wn1     <- c( NA, a$wn[1:(nrow(a)-1)] )#
a$wn1[a$firstlast==1] <- NA#
#
a$s2      <- ifelse( a$wn2 > a$wn+1, 1, 0 )#
a$s2F     <- factor(a$s2)#
levels(a$s2F) <- c("before non-skip","before skip")#
#
# determine freq classes for plotting#
#BRE  <- c(-Inf, 10^seq(0,4,0.5), Inf)#
BRE  <- c(-Inf,10,100,1000,10000,Inf)#
a$f2C  <- cut(a$f2, breaks=BRE)#
levels(a$f2C)	<- c(1:(length(BRE)-1))#
a$f2C	<- as.numeric(as.character(a$f2C))#
#
# filter fixations#
nrow(a)#
a <- subset(a, fn1st!=0)        # find firstpass fixations#
nrow(a)#
a <- subset(a, wn!=1 & wn<nw-1) # remove fixations on first and last word per sentence#
nrow(a)#
a <- subset(a, firstlast==0)     # remove first & last fixation per sentence#
nrow(a)#
#
#
#i1st <- subset(a, FixNonWord==0)     # initial fixation case#
#s1st <- subset(a, SFC==1)            # single fixation case#
#x1st <- subset(a, SFC==1 & wn2>wn)   # SFC + forward-directed outgoing saccade#
x1st <- subset(a, SFC==1 & wn1==wn-1 & wn2>wn) # SFC + last word was fixated + forward-directed outgoing saccade#
sim   <- x1st#
nrow(sim)#
rm(a)#
#
#------------------------------------------------------------------------------------#
# load experimental data#
#------------------------------------------------------------------------------------#
corpD	<- corp#
if (corp=="SHUFb_reducedDelta1") corpD	<- "SHUF"#
#
ipath <- "/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/"#
ifile <- paste(corpD,"_abc_iR1st.rda",sep="")#
#ifile <- "PSC275_abc_xB1st.rda" # -> additional: binocular criterium#
load(file=paste(ipath,corpD,"_",samp,"/",ifile,sep=""))#
b$l2 <- 1/b$l2#
dat <- subset(b, wn1.x==wn-1 & wn2.x>wn)#
dat <- dat[, c("dur","s2","l2","f2") ]#
nrow(dat)#
#
rm(a,b,c)#
#
#
# define variables#
#skipping#
dat$s2F         <- factor(dat$s2)#
levels(dat$s2F) <- c("before non-skip","before skip")#
# freq classes#
#BRE  <- c(-Inf, 10^seq(0,4,0.5), Inf)#
BRE  <- c(-Inf,10,100,1000,10000,Inf)#
dat$f2C	<- cut(10^dat$f2, breaks=BRE)#
levels(dat$f2C)	<- c(1:(length(BRE)-1))#
dat$f2C	<- as.numeric(as.character(dat$f2C))#
#
#------------------------------------------------------------------------------------#
#### average per l, f, p of the next word#
#------------------------------------------------------------------------------------#
#
#----------------------------------------------------------------#
# 1) aggregate#
#----------------------------------------------------------------#
#
#length#
aml <- melt(sim, id=c("l2" ,"s2F"), measure=c("dur")) # a = SWIFT#
dml <- melt(dat, id=c("l2" ,"s2F"), measure=c("dur")) # d = Experiment#
aml <- subset(aml, l2<11)#
dml <- subset(dml, l2<11)#
asl <- data.frame(cast(aml, l2 + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsl <- data.frame(cast(dml, l2 + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asld<- data.frame(cast(aml, l2 ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsld<- data.frame(cast(dml, l2 ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asld$data <- "SWIFT 3"# "Simulation"#
dsld$data <- "Experiment"#
asld      <- rbind(asld, dsld)#
asld$Difference   <- asld$before.skip_mean - asld$before.non.skip_mean#
# check!! formula for non-paired t.test!!#
asld$se           <- sqrt((asld$before.skip_se^2 + asld$before.non.skip_se^2)/2)#
#
#freq#
amf <- melt(sim, id=c("f2C","s2F"), measure=c("dur"))#
dmf <- melt(dat, id=c("f2C","s2F"), measure=c("dur"))#
asf <- data.frame(cast(amf, f2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsf <- data.frame(cast(dmf, f2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asfd<- data.frame(cast(amf, f2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsfd<- data.frame(cast(dmf, f2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asfd$data <- "SWIFT 3"# "Simulation"#
dsfd$data <- "Experiment"#
asfd      <- rbind(asfd, dsfd)#
asfd$Difference   <- asfd$before.skip_mean - asfd$before.non.skip_mean#
asfd$se           <- sqrt((asfd$before.skip_se^2 + asfd$before.non.skip_se^2)/2)#
#
#
#length#
print(nrow(sim))#
print(nrow(dat))#
sim <- subset(sim, l2<11)#
dat <- subset(dat, l2<11)#
print(nrow(sim))#
print(nrow(dat))#
sim$l2C	<- cut(sim$l2, b=c(0,6.5,8.5,22))#
levels(sim$l2C)	<- c("Short Words\n[2-6 let]","Middle Length\n[7-8]","Long Words\n[8-10 let]")#
dat$l2C	<- cut(dat$l2, b=c(0,6.5,8.5,22))#
levels(dat$l2C)	<- c("Short Words\n[2-6 let]","Middle Length\n[7-8]","Long Words\n[8-10 let]")#
amlC <- melt(sim, id=c("l2C" ,"s2F"), measure=c("dur")) # a = SWIFT#
dmlC <- melt(dat, id=c("l2C" ,"s2F"), measure=c("dur")) # d = Experiment#
aslC <- data.frame(cast(amlC, l2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dslC <- data.frame(cast(dmlC, l2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asldC<- data.frame(cast(amlC, l2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsldC<- data.frame(cast(dmlC, l2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asldC$data <- "SWIFT 3"# "Simulation"#
dsldC$data <- "Experiment"#
asldC      <- rbind(asldC, dsldC)#
asldC$Difference   <- asldC$before.skip_mean - asldC$before.non.skip_mean#
# check!! formula for non-paired t.test!!#
asldC$se           <- sqrt((asldC$before.skip_se^2 + asldC$before.non.skip_se^2)/2)#
#
#
#
if (corp=="SHUF")	corp1	<- "Shuffled Text"#
if (corp=="PSC275")	corp1	<- "Normal Text"#
if (corp=="SHUFb_reducedDelta1")	corp1	<- "Shuffled\n-delta1"#
asf$corp <- dsf$corp <- asl$corp <- dsl$corp <- asfd$corp <- asld$corp <- corp1#
aslC$corp <- dslC$corp <- asldC$corp	<- corp1#
#
ASF[[ic]] <- asf#
DSF[[ic]] <- dsf#
ASL[[ic]] <- asl#
DSL[[ic]] <- dsl#
#
ASLD[[ic]] <- asld#
ASFD[[ic]] <- asfd#
#
#
ASLc[[ic]] <- aslC#
DSLc[[ic]] <- dslC#
ASLDc[[ic]] <- asldC#
#
} # for (ic in 1:length(corp)) {#
#
#
rm(asf,dsf,  asl,dsl,  asld,asfd,   aslC,dslC,asldC)#
asf  <- ASF[[1]]#
dsf  <- DSF[[1]]#
asl  <- ASL[[1]]#
dsl  <- DSL[[1]]#
asfd <- ASFD[[1]]#
asld <- ASLD[[1]]#
aslC <- ASLc[[1]]#
dslC <- DSLc[[1]]#
asldC<- ASLDc[[1]]#
if (length(CORP)>1) for (i in 2:length(CORP)) {#
  asf <- rbind(asf, ASF[[i]])#
  dsf <- rbind(dsf, DSF[[i]])#
  asl <- rbind(asl, ASL[[i]])#
  dsl <- rbind(dsl, DSL[[i]])#
#
  asfd <- rbind(asfd, ASFD[[i]])#
  asld <- rbind(asld, ASLD[[i]])#
#
  aslC <- rbind(aslC, ASLc[[i]])#
  dslC <- rbind(dslC, DSLc[[i]])#
  asldC<- rbind(asldC, ASLDc[[i]])#
}#
#
skipLabel	<- c("non-skip","before-skip")#
levels(asl$s2F)	<- skipLabel#
levels(asf$s2F)	<- skipLabel#
levels(dsl$s2F)	<- skipLabel#
levels(dsf$s2F)	<- skipLabel#
#
levels(aslC$s2F)	<- skipLabel#
levels(dslC$s2F)	<- skipLabel#
#
#
asl$corp	<- factor(asl$corp)#
asf$corp	<- factor(asf$corp)#
dsl$corp	<- factor(dsl$corp)#
dsf$corp	<- factor(dsf$corp)#
asld$corp	<- factor(asld$corp)#
asfd$corp	<- factor(asfd$corp)#
#
aslC$corp	<- factor(aslC$corp)#
dslC$corp	<- factor(dslC$corp)#
asldC$corp	<- factor(asldC$corp)#
#
asl$corp	<- factor(asl$corp, levels=levels(asl$corp)[c(2,3,1)])#
asf$corp	<- factor(asf$corp, levels=levels(asf$corp)[c(2,3,1)])#
dsl$corp	<- factor(dsl$corp, levels=levels(dsl$corp)[c(2,3,1)])#
dsf$corp	<- factor(dsf$corp, levels=levels(dsf$corp)[c(2,3,1)])#
#
asld$corp	<- factor(asld$corp, levels=levels(asld$corp)[c(2,3,1)])#
asfd$corp	<- factor(asfd$corp, levels=levels(asfd$corp)[c(2,3,1)])#
#
aslC$corp	<- factor(aslC$corp , levels=levels(aslC$corp )[c(2,3,1)])#
dslC$corp	<- factor(dslC$corp , levels=levels(dslC$corp )[c(2,3,1)])#
asldC$corp	<- factor(asldC$corp, levels=levels(asldC$corp)[c(2,3,1)])#
#
#
print("aggregate & plotting ...")#
#----------------------------------------------------------------#
# 2) plot#
#----------------------------------------------------------------#
if (FALSE) { #
ymin  <- floor(   min(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
#ymin  <- ymin - 20#
ymax  <- ceiling( max(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ybre  <- seq(ymin, ymax, by=20)#
asl$data	<- "SWIFT 3"# "Simulation"#
dsl$data	<- "Experiment"#
sl			<- rbind(asl, dsl)#
sl$data		<- factor(sl$data)#
p.sl <- qplot(x=l2, y=dur_mean, data=sl, geom=c("line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,  facets=data~.,#
    linetype=s2F, shape=s2F, colour=corp, width=0.3, main=" ")+#
    scale_colour_hue(name="", legend=FALSE)+#
    scale_linetype(name="") + scale_shape(name="")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position=c(0.38,0.46))#
ymin  <- floor(   min(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
ymax  <- ceiling( max(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
#ymax  <- ymax + 20#
ybre  <- seq(ymin, ymax, by=25)#
asld$data	<- factor(asld$data)#
p.sld <- qplot(x=l2, y=Difference, data=asld, geom=c("line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	colour=corp, width=0.3, facets=data~.,#
	main="    (Skip) -- (Non-Skip)") + #
	scale_colour_hue(name="") + #
	scale_linetype(name="") + scale_shape(name="")+#
	scale_x_continuous(name="         Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybre)+#
	coord_cartesian(ylim=c(ymin, ymax))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(-0.16,0.50))#
quartz(width=7.8, height=6)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(p.sl, vp = viewport(layout.pos.row = 1, layout.pos.col = 1:44))#
print(p.sld, vp = viewport(layout.pos.row = 1, layout.pos.col = 58:100))#
#
dev.copy2eps(file="skipsimple2mL.eps")#
#
#
print("black/wight ..")#
#----------------------------------------------------------------#
# 2) Schwarz - Weiß#
#----------------------------------------------------------------#
ymin  <- floor(   min(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
#ymin  <- ymin - 20#
ymax  <- ceiling( max(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ybre  <- seq(ymin, ymax, by=20)#
asl$data	<- "Simulation"#
dsl$data	<- "Experiment"#
sl			<- rbind(asl, dsl)#
sl$data		<- factor(sl$data)#
p.sl <- qplot(x=l2, y=dur_mean, data=sl, geom=c("line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,  facets=data~.,#
    linetype=s2F, shape=s2F, colour=corp, width=0.3, main=" ")+#
    scale_colour_grey(name="", legend=FALSE)+#
    scale_linetype(name="") + scale_shape(name="")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position=c(0.38,0.46))#
ymin  <- floor(   min(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
ymax  <- ceiling( max(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
#ymax  <- ymax + 20#
ybre  <- seq(ymin, ymax, by=25)#
asld$data	<- factor(asld$data)#
p.sld <- qplot(x=l2, y=Difference, data=asld, geom=c("line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	colour=corp, width=0.3, facets=data~.,#
	main="    (Skip) -- (Non-Skip)") + #
	scale_colour_grey(name="") + #
	scale_linetype(name="") + scale_shape(name="")+#
	scale_x_continuous(name="         Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybre)+#
	coord_cartesian(ylim=c(ymin, ymax))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(-0.16,0.50))#
dev.off()#
quartz(width=7.8, height=6)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(p.sl, vp = viewport(layout.pos.row = 1, layout.pos.col = 1:44))#
print(p.sld, vp = viewport(layout.pos.row = 1, layout.pos.col = 58:100))#
#
dev.copy2eps(file="skipsimple2mL_SW.eps")#
#
#
qplot(x=l2, y=dur_mean, data=dsl, geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,  #facets=data~.,#
    linetype=s2F, shape=s2F, colour=corp, width=0.3, main=" ")+#
    scale_colour_grey(name="", legend=FALSE)+#
    scale_linetype(name="") + scale_shape(name="")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position=c(0.38,0.46))#
qplot(x=l2, y=Difference, data=subset(asld,data=="Simulation"), #
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	colour=corp, width=0.3, #facets=data~.,#
	main="    (Skip) -- (Non-Skip)") + #
	scale_colour_grey(name="") + #
	scale_linetype(name="") + scale_shape(name="")+#
	scale_x_continuous(name="         Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybre)+#
	coord_cartesian(ylim=c(ymin, ymax))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() #+ opts(legend.position=c(-0.16,0.50))#
#
#
#
#----------------------------------------------------------------#
# 2a) Schwarz - Weiß#
#----------------------------------------------------------------#
ymin  <- floor(   min(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
#ymin  <- ymin - 20#
ymax  <- ceiling( max(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ybre  <- seq(ymin, ymax, by=20)#
asl$data	<- "Simulation"#
dsl$data	<- "Experiment"#
sl			<- rbind(asl, dsl)#
sl$data		<- factor(sl$data)#
p.asl <- qplot(x=l2, y=dur_mean, data=asl, geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,  #facets=data~.,#
    linetype=s2F, shape=s2F, colour=corp, width=0.3, main="    Simulation")+#
    scale_colour_grey(name="", legend=FALSE)+#
    scale_linetype(name="") + scale_shape(name="")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position=c(0.40,0.78))#
p.dsl <- qplot(x=l2, y=dur_mean, data=dsl, geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,  #facets=data~.,#
    linetype=s2F, shape=s2F, colour=corp, width=0.3, main="    Experiment")+#
    scale_colour_grey(name="", legend=FALSE)+#
    scale_linetype(name="") + scale_shape(name="")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position=c(0.40,0.78))#
ymind  <- floor(   min(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
ymaxd  <- ceiling( max(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
#ymax  <- ymax + 20#
ybred  <- seq(ymind, ymaxd, by=25)#
asld$data	<- factor(asld$data)#
p.dsld <- qplot(x=l2, y=Difference, data=subset(asld,data=="Experiment"), #
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	colour=corp, width=0.3, #facets=data~.,#
	main="    Experiment") + #
	scale_colour_grey(name="") + #
	scale_linetype(name="") + scale_shape(name="")+#
	scale_x_continuous(name="         Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(0.05,0.04))#
p.asld <- qplot(x=l2, y=Difference, data=subset(asld,data=="Simulation"), #
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	colour=corp, width=0.3, #facets=data~.,#
	main="    Simulation") + #
	scale_colour_grey(name="", legend=FALSE) + #
	scale_linetype(name="") + scale_shape(name="")+#
	scale_x_continuous(name="         Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(0.1,0.50))#
dev.off()#
quartz(width=6.7, height=6)#
pushViewport(viewport(layout = grid.layout(100, 100)))#
print(p.dsl, vp = viewport(layout.pos.row =  1: 50, layout.pos.col =  1: 48))#
print(p.asl, vp = viewport(layout.pos.row = 51:100, layout.pos.col =  1: 48))#
print(p.dsld,vp = viewport(layout.pos.row =  1: 50, layout.pos.col = 52:100))#
print(p.asld,vp = viewport(layout.pos.row = 51:100, layout.pos.col = 52:100))#
#
dev.copy2eps(file="skipsimple2mLb_SW.eps")#
#
#
#
#
#
#
#
#
#
#
#----------------------------------------------------------------#
# 2b) Schwarz - Weiß#
#----------------------------------------------------------------#
ymin  <- floor(   min(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
#ymin  <- ymin - 20#
ymax  <- ceiling( max(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ybre  <- seq(ymin, ymax, by=20)#
asl$data	<- "SWIFT 3"# "Simulation"#
dsl$data	<- "Experiment"#
sl			<- rbind(asl, dsl)#
sl$data		<- factor(sl$data)#
p.asl <- qplot(x=l2, y=dur_mean, data=asl, geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,  #facets=data~.,#
    linetype=s2F, shape=s2F, colour=corp, width=0.3, main="    Simulation")+#
    scale_colour_grey(name="", legend=FALSE)+#
    scale_linetype(name="") + scale_shape(name="")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position=c(0.40,0.78))#
p.dsl <- qplot(x=l2, y=dur_mean, data=dsl, geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,  #facets=data~.,#
    linetype=s2F, shape=s2F, colour=corp, width=0.3, main="    Experiment")+#
    scale_colour_grey(name="", legend=FALSE)+#
    scale_linetype(name="") + scale_shape(name="")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position=c(0.40,0.78))#
ymind  <- floor(   min(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
ymaxd  <- ceiling( max(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
#ymax  <- ymax + 20#
ybred  <- seq(ymind, ymaxd, by=25)#
asld$data	<- factor(asld$data)#
p.dsld <- qplot(x=l2, y=Difference, data=subset(asld,corp=="Normal Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=data, shape=data, colour=corp, width=0.3, #facets=data~.,#
	main="    Normal Text")+#
	scale_colour_grey(name="")+#
	scale_linetype(name="") + scale_shape(name="")+#
	scale_x_continuous(name="         Word Length [let]")+#
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(0.05,0.04))#
p.asld <- qplot(x=l2, y=Difference, data=subset(asld,corp=="Shuffled Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=data, shape=data, colour=corp, width=0.3, #facets=data~.,#
	main="    Shuffled Text") + #
	scale_colour_grey(name="", legend=FALSE) + #
	scale_linetype(name="") + scale_shape(name="")+#
	scale_x_continuous(name="         Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(0.1,0.50))#
dev.off()#
quartz(width=6.7, height=6)#
pushViewport(viewport(layout = grid.layout(100, 100)))#
print(p.dsl, vp = viewport(layout.pos.row =  1: 50, layout.pos.col =  1: 48))#
print(p.asl, vp = viewport(layout.pos.row = 51:100, layout.pos.col =  1: 48))#
print(p.dsld,vp = viewport(layout.pos.row =  1: 50, layout.pos.col = 52:100))#
print(p.asld,vp = viewport(layout.pos.row = 51:100, layout.pos.col = 52:100))#
#
dev.copy2eps(file="skipsimple2mLc_SW.eps")#
#
#
}#
#
#
#
#
#
#----------------------------------------------------------------#
# 2b) Schwarz - Weiß#
#----------------------------------------------------------------#
ymin  <- floor(   min(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ymax  <- ceiling( max(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ybre  <- seq(ymin, ymax, by=20)#
asl$data	<- "SWIFT 3"# "Simulation"#
dsl$data	<- "Experiment"#
sl			<- rbind(asl, dsl)#
sl$data		<- factor(sl$data)#
# Experiment#
p.dnl <- qplot(x=l2, y=dur_mean, data=subset(dsl,corp=="Normal Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=corp, width=0.3, main="    Experiment")+#
    scale_colour_grey(name="", legend=FALSE)+ scale_shape(name="")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position=c(1.1,0.02))#
p.dsl <- qplot(x=l2, y=dur_mean, data=subset(dsl,corp!="Normal Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=corp, width=0.3, main="    Experiment")+#
    scale_colour_grey(name="", legend=FALSE)+ scale_shape(name="") +#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
#
# Simulation#
p.anl <- qplot(x=l2, y=dur_mean, data=subset(asl,corp=="Normal Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=corp, width=0.3, main="    Simulation")+#
    scale_colour_grey(name="")+ scale_shape(name="", legend=FALSE) +#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position=c(1.15,0.02))#
p.asl <- qplot(x=l2, y=dur_mean, data=subset(asl,corp!="Normal Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=corp, width=0.3, main="    Simulation")+#
    scale_colour_grey(name="", legend=FALSE)+ scale_shape(name="") +#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
#
#
ymind  <- floor(   min(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
ymaxd  <- ceiling( max(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
#ymax  <- ymax + 20#
ybred  <- seq(ymind, ymaxd, by=25)#
asld$data	<- factor(asld$data)#
p.dnld <- qplot(x=l2, y=Difference, data=subset(asld,corp=="Normal Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=data, colour=corp, width=0.3,#
	main="       (Skip) -- (Non-Skip)")+#
	scale_colour_grey(name="", legend=FALSE)+#
	scale_linetype_manual(name="", values=c(4,2))+#
	scale_x_continuous(name="         Word Length [let]")+#
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(0.40,0.78))#
p.dsld <- qplot(x=l2, y=Difference, data=subset(asld,corp!="Normal Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=data, colour=corp, width=0.3, #
	main="       (Skip) -- (Non-Skip)") + #
	scale_colour_grey(name="", legend=FALSE) + #
	scale_linetype_manual(name="", values=c(4,2))+#
	scale_x_continuous(name="         Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(0.40,0.78))#
#
levels(asldC$corp)	<- c("Shuffled\ndelta1","Shuffled","Normal")#
levels(asldC$l2C)	<- c("short [2-6]","Middle Length\n[7-8]","long [9-10]")#
#dev.off()#
quartz(width=4.3,height=3)#
print(  p.sub <- qplot(x=corp, y=Difference, fill=data, facets=.~l2C,#
	xlab="      ", ylab="", ymin=Difference-se, ymax=Difference+se,#
	data=subset(asldC,l2C!="Middle Length\n[7-8]"), geom=c("bar","errorbar"), position="dodge") + #
	geom_hline(yintercept=0) + scale_fill_grey(name="") + theme_bw() + #
	opts(legend.position=c(0.3,0.8))   )#c(0.7,1.1)#
ggsave(paste("skipsimple2mLc_SW_bar_",samp,"_delta.eps",sep=""))#
#
#dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(100, 100)))#
#
print(p.dnl , vp = viewport(layout.pos.row =  1: 50, layout.pos.col =  1: 33))#
print(p.anl , vp = viewport(layout.pos.row =  1: 50, layout.pos.col = 34: 66))#
print(p.dnld, vp = viewport(layout.pos.row =  1: 50, layout.pos.col = 67:100))#
#
print(p.dsl , vp = viewport(layout.pos.row = 51:100, layout.pos.col =  1: 33))#
print(p.asl , vp = viewport(layout.pos.row = 51:100, layout.pos.col = 34: 66))#
print(p.dsld, vp = viewport(layout.pos.row = 51:100, layout.pos.col = 67:100))#
#
#
#print(p.sub, vp = viewport(layout.pos.row = 55:82, layout.pos.col = 72:98))#
#
dev.copy2eps(file=paste("skipsimple2mLc_SW_",samp,"_delta.eps",sep=""))#
#
#
#
p.dnld <- qplot(x=l2, y=Difference, data=subset(asld,corp=="Normal Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=data, colour=corp, width=0.3,#
	main="       (Skip) -- (Non-Skip)")+#
	scale_colour_grey(name="", legend=FALSE)+#
	scale_linetype_manual(name="", values=c(2,1), legend=FALSE)+#
	scale_x_continuous(name="         Word Length [let]")+#
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(0.40,0.78))#
p.dsld <- qplot(x=l2, y=Difference, data=subset(asld,corp!="Normal Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=data, colour=corp, width=0.3, #
	main="       (Skip) -- (Non-Skip)") + #
	scale_colour_grey(name="") + #
	scale_linetype_manual(name="", values=c(2,1))+#
	scale_x_continuous(name="         Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()#
quartz(width=8, height=3)#
pushViewport(viewport(layout = grid.layout(100, 100)))#
print(p.dnld, vp = viewport(layout.pos.row =  1:100, layout.pos.col =  1: 38))#
print(p.dsld, vp = viewport(layout.pos.row =  1:100, layout.pos.col = 39: 92))#
dev.copy2eps(file=paste("skipsimple2mLd_SW_",samp,"_delta.eps",sep=""))
str(asld)
levels(asld$corp)
asld$corp2	<- asld$corp#
levels(asld$corp2)
levels(asld$corp2)	<- c("Shuffled Text", "Shuffled Text", "Normal Text")
qplot(x=l2, y=Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=corp, width=0.3,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)
quartz(width=8, height=3)#
pushViewport(viewport(layout = grid.layout(100, 100)))#
print(p.dnld, vp = viewport(layout.pos.row =  1:100, layout.pos.col =  1: 38))#
print(p.dsld, vp = viewport(layout.pos.row =  1:100, layout.pos.col = 39: 92))
quartz(width=8, height=3)#
qplot(x=l2, y=Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=corp, width=0.3,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)
asld$corp2			<- factor(asld$corp2, levels=levels(asld$corp2)[2:1])
quartz(width=8, height=3)#
qplot(x=l2, y=Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=corp, width=0.3,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)
qplot(x=l2, y=Difference, data=asld, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=data, width=0.3,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)
asld$dat2	<- asld$corp
levels(asld$dat2)
asld$dat2	<- paste(asld$corp, asld$dat, sep=" - ")
levels(asld$dat2)
asld$dat2	<- paste(asld$corp, asld$dat, sep=" - ")
asld$dat2	<- factor( paste(asld$corp, asld$dat, sep=" - ") )
levels(asld$dat2)
asld$dat2	<- factor( paste(asld$corp, asld$data, sep=" - ") )
levels(asld$dat2)
dat2	<- subset(asld, dat2!="Shuffled\n-delta1 - Experiment")
levels(dat2$dat2)
dat2$dat2	<- factor(dat2$dat2)
levels(dat2$dat2)
levels(dat2$dat2)	<- c("Experiment", "SWIFT 3", "SWIFT 3 - delta_1", "Experiment", "SWIFT 3")
levels(dat2$dat2)
quartz(width=8, height=3)#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)
quartz(width=7, height=3)#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)
ybred
c(ymind, ymaxd)
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_linetype_manual(name="", values=c(1,2,4))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3,shape=1,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_linetype_manual(name="", values=c(1,2,4))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
x
x<-1:21
qplot(x,x,geom="point",shape=x)
quartz(width=7, height=3.5)#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3,shape=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_shape_manual(value=c(20,20,8))+#
	scale_linetype_manual(name="", values=c(1,2,4))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
#
quartz(width=7, height=3.5)#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3, shape=dat2, colour=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_grey_manual(value=c("grey40","grey40","black"))+#
	scale_shape_manual(value=c(20,20,8))+#
	scale_linetype_manual(name="", values=c(1,2,4))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3, shape=dat2, colour=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_colour_grey(value=c("grey40","grey40","black"))+#
	scale_shape_manual(value=c(20,20,8))+#
	scale_linetype_manual(name="", values=c(1,2,4))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3, shape=dat2, colour=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_colour_manual(value=c("grey50","grey50","black"))+#
	scale_shape_manual(value=c(20,20,8))+#
	scale_linetype_manual(name="", values=c(1,2,4))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3, shape=dat2, colour=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_colour_manual(value=c("grey50","grey50","black"))+#
	scale_shape_manual(value=c(21,21,8))+#
	scale_linetype_manual(name="", values=c(1,2,4))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3, shape=dat2, colour=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_colour_manual(value=c("grey40","grey40","black"))+#
	scale_shape_manual(value=c(21,21,8))+#
	scale_linetype_manual(name="", values=c(1,2,4))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3, shape=dat2, colour=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_colour_manual(name="",value=c("grey40","grey40","black"))+#
	scale_shape_manual(value=c(21,21,8))+#
	scale_linetype_manual(name="", values=c(1,2,4))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3, shape=dat2, colour=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_shape(name="")+#
	scale_colour_manual(name="",value=c("grey40","grey40","black"))+#
	scale_shape_manual(value=c(21,21,8))+#
	scale_linetype_manual(name="", values=c(1,2,4))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3, shape=dat2, colour=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_colour_manual(name="",value=c("grey40","grey40","black"))+#
	scale_shape_manual(name="",value=c(21,21,8))+#
	scale_linetype_manual(name="", values=c(1,2,4))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3, shape=dat2, colour=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_colour_manual(name="",value=c("grey40","grey40","black"))+#
	scale_shape_manual(name="",value=c(21,21,8))+#
	scale_linetype_manual(name="", values=c(2,1,1))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3, shape=dat2, colour=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_colour_manual(name="",value=c("grey40","grey40","black"))+#
	scale_shape_manual(name="",value=c(21,21,8))+#
	scale_linetype_manual(name="", values=c(3,1,1))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3, shape=dat2, colour=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_colour_manual(name="",value=c("grey40","grey40","black"))+#
	scale_shape_manual(name="",value=c(21,21,8))+#
	scale_linetype_manual(name="", values=c(4,1,1))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
#
quartz(width=7, height=3.5)#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3, shape=dat2, colour=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_colour_manual(name="",value=c("grey40","grey40","black"))+#
	scale_shape_manual(name="",value=c(21,21,8))+#
	scale_linetype_manual(name="", values=c(4,1,1))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
#
quartz(width=7, height=3.5)#
qplot(x=l2, y=Difference, data=dat2, geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	linetype=dat2, width=0.3, shape=dat2, colour=dat2,#
	main="       (Skip) - (Non-Skip)")+#
	facet_grid(.~corp2)+#
	scale_colour_manual(name="Data",value=c("grey40","grey40","black"))+#
	scale_shape_manual(name="Data",value=c(21,21,8))+#
	scale_linetype_manual(name="Data", values=c(4,1,1))+#
	scale_x_continuous(name="Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw()
dev.copy2eps(file=paste("skipsimple2mLd_SW_",samp,"_delta1.eps",sep=""))
source("xskipsimple2mL_delta1.R")
source("xskipsimple2mL_delta1.R")
source("xnewgofplot2m_delta.R")
source("xnewgofplot2m_delta.R")
#
SIM  	<- read.table("../sim.vers")[[1]]#
#SIM	<- "14a_newgoffid"#
#
CORP	<- c("SHUF","PSC275")  # c("SHUF","PSC275","PSC30")#
samp 	<- 0#
#
#
print(paste("sim-Version: ",SIM,sep=""))#
#
ASF  	<- DSF  <- ASL  <- DSL  <- ASLD  <- ASFD  <- list()#
ASLc	<- DSLc	<- ASLDc	<- list()#
for (ic in c(1:length(CORP)) ) {#
#
corp 	<- CORP[ic]#
print(paste("process ",corp," ...",sep=""))#
#
#------------------------------------------------------------------------------------#
# load simulated data#
#------------------------------------------------------------------------------------#
ifile1    <- paste("../",SIM,corp,"/seq.dat",sep="")#
incol	   <- c("id","sn","wn","let","dur","st1","ao1","l","f","p","firstlast","fn1st","SFC","FixNonWord","nFixOnWord","testreg","x12")#
a	       <- read.table(ifile1, sep="	", col.names=incol, na.strings="-999")#
# firstlast = codes first and last fixation in a sentence. 1 = first, 2 = last, 0 = all others#
# st1 (alternative: n_skp_wrds) = saccade type of the previous saccade (1 = forward, 0 = refixation, 2 = skipping, -1 = regression to last word, ..)#
# fn1st = fixation number in first pass; 1 = first fixation on the word in firstpass reading; 2 = second fixation on the word in firstpass reading; 0 = more-pass reading fixation#
# SFC = Anzahl der Fixationen auf dem Wort im firstpass. 1 = single fixation case, 2 = 2-fixation case#
# FixNonWord = Fixation Nr. n auf dem fixierten Wort (1. Fixation = 0)#
# nFixOnWord = Anzahl der Fixationen auf dem fixierten Wort wÃ¤hrend des Lesens dieses Satzes (1 Fixation = 0; bis ...)#
#
#
#------------------------------------------------------------------------------------#
# add corpus info: nw, l2, f2, p2#
#------------------------------------------------------------------------------------#
ifile2    <- paste("../",SIM,corp,"/freq.dat",sep="")#
exp       <- read.table(ifile2)#
depvars   <- c("d1","d2","d0","trt", "p0","p2","p3","rgc")#
if (dim(exp)[2]==18) agg <- "pW"#
if (dim(exp)[2]==19) agg <- "pSW"#
if (agg=="pW" ) ivars <- c("sd1", "sd2", "sd0", "strt")#
if (agg=="pSW") ivars <- c("id",  "sn" , "wn" , "PSCsn","PSCwn")#
names(exp)	<- c("sn","wn","l","f","p", depvars, ivars, "nw")#
if (agg=="pW" ) exp <- exp[, !names(exp)%in%ivars ]#
word      <- exp[, !names(exp)%in%depvars]#
exp       <- exp[,  names(exp)%in%depvars]#
word[, c("l2","f2","p2")] <- rbind( word[2:nrow(word), c("l","f","p")], c(NA,NA,NA)  )#
word[word$wn==word$nw, c("l2","f2","p2")] <- c(NA, NA, NA)#
#match corpus info to data#
if (agg=="pW" ) did       <-                     a$sn*100 +    a$wn#
if (agg=="pW" ) cid       <-                  word$sn*100 + word$wn#
if (agg=="pSW") did       <-    a$id*100000 +    a$sn*100 +    a$wn # valid for id <= 999#
if (agg=="pSW") cid       <- word$id*100000 + word$sn*100 + word$wn#
idx_isw   <- match(did, cid)#
cvars     <- c("nw","l2","f2","p2")#
a[,cvars] <- word[idx_isw,cvars]#
#------------------------------------------------------------------------------------#
#
#------------------------------------------------------------------------------------#
# data processing: define variables + data selection#
#------------------------------------------------------------------------------------#
# find fixations before skip & before non-skip#
a$wn2     <- c( a$wn[2:nrow(a)], NA )#
a$wn2[a$firstlast==2] <- NA#
a$wn1     <- c( NA, a$wn[1:(nrow(a)-1)] )#
a$wn1[a$firstlast==1] <- NA#
#
a$s2      <- ifelse( a$wn2 > a$wn+1, 1, 0 )#
a$s2F     <- factor(a$s2)#
levels(a$s2F) <- c("before non-skip","before skip")#
#
# determine freq classes for plotting#
#BRE  <- c(-Inf, 10^seq(0,4,0.5), Inf)#
BRE  <- c(-Inf,10,100,1000,10000,Inf)#
a$f2C  <- cut(a$f2, breaks=BRE)#
levels(a$f2C)	<- c(1:(length(BRE)-1))#
a$f2C	<- as.numeric(as.character(a$f2C))#
#
# filter fixations#
nrow(a)#
a <- subset(a, fn1st!=0)        # find firstpass fixations#
nrow(a)#
a <- subset(a, wn!=1 & wn<nw-1) # remove fixations on first and last word per sentence#
nrow(a)#
a <- subset(a, firstlast==0)     # remove first & last fixation per sentence#
nrow(a)#
#
#
#i1st <- subset(a, FixNonWord==0)     # initial fixation case#
#s1st <- subset(a, SFC==1)            # single fixation case#
#x1st <- subset(a, SFC==1 & wn2>wn)   # SFC + forward-directed outgoing saccade#
x1st <- subset(a, SFC==1 & wn1==wn-1 & wn2>wn) # SFC + last word was fixated + forward-directed outgoing saccade#
sim   <- x1st#
nrow(sim)#
rm(a)#
#
#------------------------------------------------------------------------------------#
# load experimental data#
#------------------------------------------------------------------------------------#
ipath <- "/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/"#
ifile <- paste(corp,"_abc_iR1st.rda",sep="")#
#ifile <- "PSC275_abc_xB1st.rda" # -> additional: binocular criterium#
load(file=paste(ipath,corp,"_",samp,"/",ifile,sep=""))#
b$l2 <- 1/b$l2#
dat <- subset(b, wn1.x==wn-1 & wn2.x>wn)#
dat <- dat[, c("dur","s2","l2","f2") ]#
nrow(dat)#
#
rm(a,b,c)#
#
# define variables#
#skipping#
dat$s2F         <- factor(dat$s2)#
levels(dat$s2F) <- c("before non-skip","before skip")#
# freq classes#
#BRE  <- c(-Inf, 10^seq(0,4,0.5), Inf)#
BRE  <- c(-Inf,10,100,1000,10000,Inf)#
dat$f2C	<- cut(10^dat$f2, breaks=BRE)#
levels(dat$f2C)	<- c(1:(length(BRE)-1))#
dat$f2C	<- as.numeric(as.character(dat$f2C))#
#
#------------------------------------------------------------------------------------#
#### average per l, f, p of the next word#
#------------------------------------------------------------------------------------#
#
#----------------------------------------------------------------#
# 1) aggregate#
#----------------------------------------------------------------#
#
#length#
aml <- melt(sim, id=c("l2" ,"s2F"), measure=c("dur")) # a = SWIFT#
dml <- melt(dat, id=c("l2" ,"s2F"), measure=c("dur")) # d = Experiment#
aml <- subset(aml, l2<11)#
dml <- subset(dml, l2<11)#
asl <- data.frame(cast(aml, l2 + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsl <- data.frame(cast(dml, l2 + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asld<- data.frame(cast(aml, l2 ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsld<- data.frame(cast(dml, l2 ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asld$data <- "SWIFT 3" # "Simulation"#
dsld$data <- "Experiment"#
asld      <- rbind(asld, dsld)#
asld$Difference   <- asld$before.skip_mean - asld$before.non.skip_mean#
# check!! formula for non-paired t.test!!#
asld$se           <- sqrt((asld$before.skip_se^2 + asld$before.non.skip_se^2)/2)#
#
#freq#
amf <- melt(sim, id=c("f2C","s2F"), measure=c("dur"))#
dmf <- melt(dat, id=c("f2C","s2F"), measure=c("dur"))#
asf <- data.frame(cast(amf, f2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsf <- data.frame(cast(dmf, f2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asfd<- data.frame(cast(amf, f2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsfd<- data.frame(cast(dmf, f2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asfd$data <- "SWIFT 3"#
dsfd$data <- "Experiment"#
asfd      <- rbind(asfd, dsfd)#
asfd$Difference   <- asfd$before.skip_mean - asfd$before.non.skip_mean#
asfd$se           <- sqrt((asfd$before.skip_se^2 + asfd$before.non.skip_se^2)/2)#
#
#
#length#
sim <- subset(sim, l2<11)#
dat <- subset(dat, l2<11)#
sim$l2C	<- cut(sim$l2, b=c(0,6.5,8.5,22))#
levels(sim$l2C)	<- c("Short Words\n[2-6 let]","Middle Length\n[7-8]","Long Words\n[8-10 let]")#
dat$l2C	<- cut(dat$l2, b=c(0,6.5,8.5,22))#
levels(dat$l2C)	<- c("Short Words\n[2-6 let]","Middle Length\n[7-8]","Long Words\n[8-10 let]")#
amlC <- melt(sim, id=c("l2C" ,"s2F"), measure=c("dur")) # a = SWIFT#
dmlC <- melt(dat, id=c("l2C" ,"s2F"), measure=c("dur")) # d = Experiment#
aslC <- data.frame(cast(amlC, l2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dslC <- data.frame(cast(dmlC, l2C + s2F ~ variable, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asldC<- data.frame(cast(amlC, l2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
dsldC<- data.frame(cast(dmlC, l2C ~ s2F, function(x) { c(mean=mean(x), se=sd(x)/sqrt(length(x))) } ))#
asldC$data <- "SWIFT 3"#
dsldC$data <- "Experiment"#
asldC      <- rbind(asldC, dsldC)#
asldC$Difference   <- asldC$before.skip_mean - asldC$before.non.skip_mean#
# check!! formula for non-paired t.test!!#
asldC$se           <- sqrt((asldC$before.skip_se^2 + asldC$before.non.skip_se^2)/2)#
#
#
#
if (corp=="SHUF")	corp1	<- "Shuffled Text"#
if (corp=="PSC275")	corp1	<- "Normal Text"#
asf$corp <- dsf$corp <- asl$corp <- dsl$corp <- asfd$corp <- asld$corp <- corp1#
aslC$corp <- dslC$corp <- asldC$corp	<- corp1#
#
ASF[[ic]] <- asf#
DSF[[ic]] <- dsf#
ASL[[ic]] <- asl#
DSL[[ic]] <- dsl#
#
ASLD[[ic]] <- asld#
ASFD[[ic]] <- asfd#
#
#
ASLc[[ic]] <- aslC#
DSLc[[ic]] <- dslC#
ASLDc[[ic]] <- asldC#
#
} # for (ic in 1:length(corp)) {#
#
#
rm(asf,dsf,  asl,dsl,  asld,asfd,   aslC,dslC,asldC)#
asf  <- ASF[[1]]#
dsf  <- DSF[[1]]#
asl  <- ASL[[1]]#
dsl  <- DSL[[1]]#
asfd <- ASFD[[1]]#
asld <- ASLD[[1]]#
aslC <- ASLc[[1]]#
dslC <- DSLc[[1]]#
asldC<- ASLDc[[1]]#
if (length(CORP)>1) for (i in 2:length(CORP)) {#
  asf <- rbind(asf, ASF[[i]])#
  dsf <- rbind(dsf, DSF[[i]])#
  asl <- rbind(asl, ASL[[i]])#
  dsl <- rbind(dsl, DSL[[i]])#
#
  asfd <- rbind(asfd, ASFD[[i]])#
  asld <- rbind(asld, ASLD[[i]])#
#
  aslC <- rbind(aslC, ASLc[[i]])#
  dslC <- rbind(dslC, DSLc[[i]])#
  asldC<- rbind(asldC, ASLDc[[i]])#
}#
#
skipLabel	<- c("non-skip","before-skip")#
levels(asl$s2F)	<- skipLabel#
levels(asf$s2F)	<- skipLabel#
levels(dsl$s2F)	<- skipLabel#
levels(dsf$s2F)	<- skipLabel#
#
levels(aslC$s2F)	<- skipLabel#
levels(dslC$s2F)	<- skipLabel#
#
#
asl$corp	<- factor(asl$corp)#
asf$corp	<- factor(asf$corp)#
dsl$corp	<- factor(dsl$corp)#
dsf$corp	<- factor(dsf$corp)#
asld$corp	<- factor(asld$corp)#
asfd$corp	<- factor(asfd$corp)#
#
aslC$corp	<- factor(aslC$corp)#
dslC$corp	<- factor(dslC$corp)#
asldC$corp	<- factor(asldC$corp)#
#
asl$corp	<- factor(asl$corp, levels=levels(asl$corp)[c(2,1)])#
asf$corp	<- factor(asf$corp, levels=levels(asf$corp)[c(2,1)])#
dsl$corp	<- factor(dsl$corp, levels=levels(dsl$corp)[c(2,1)])#
dsf$corp	<- factor(dsf$corp, levels=levels(dsf$corp)[c(2,1)])#
#
asld$corp	<- factor(asld$corp, levels=levels(asld$corp)[c(2,1)])#
asfd$corp	<- factor(asfd$corp, levels=levels(asfd$corp)[c(2,1)])#
#
aslC$corp	<- factor(aslC$corp , levels=levels(aslC$corp )[c(2,1)])#
dslC$corp	<- factor(dslC$corp , levels=levels(dslC$corp )[c(2,1)])#
asldC$corp	<- factor(asldC$corp, levels=levels(asldC$corp)[c(2,1)])#
#
#
print("aggregate & plotting ...")#
#----------------------------------------------------------------#
# 2) plot#
#----------------------------------------------------------------#
#----------------------------------------------------------------#
# 2b) Schwarz - Weiß#
#----------------------------------------------------------------#
ymin  <- floor(   min(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ymax  <- ceiling( max(c(asl$dur_mean, asf$dur_mean, dsl$dur_mean, dsf$dur_mean)) /10)*10#
ybre  <- seq(ymin, ymax, by=20)#
asl$data	<- "SWIFT 3" #"Simulation"#
dsl$data	<- "Experiment"#
sl			<- rbind(asl, dsl)#
sl$data		<- factor(sl$data)#
# Experiment#
p.dnl <- qplot(x=l2, y=dur_mean, data=subset(dsl,corp=="Normal Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Experiment")+#
    scale_colour_manual(  name="", values="grey", legend=FALSE)+#
    scale_shape_manual(   name="", values=c(2,3))+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position=c(1.1,0.02))#
p.dsl <- qplot(x=l2, y=dur_mean, data=subset(dsl,corp=="Shuffled Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Experiment")+#
    scale_colour_manual(  name="", values="grey", legend=FALSE)+#
    scale_shape_manual(   name="", values=c(2,3))+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
#
# Simulation#
p.anl <- qplot(x=l2, y=dur_mean, data=subset(asl,corp=="Normal Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Simulation")+#
    scale_colour_manual(  name="", values="black")+ #
    scale_shape_manual(   name="", values=c(2,3), legend=FALSE)+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
p.asl <- qplot(x=l2, y=dur_mean, data=subset(asl,corp=="Shuffled Text"), geom=c("errorbar","line","point"), #
	ymin=dur_mean-dur_se, ymax=dur_mean+dur_se,#
    shape=s2F, colour=data, width=0.3, main="    Simulation")+#
    scale_colour_manual(  name="", values="black", legend=FALSE)+#
    scale_shape_manual(   name="", values=c(2,3))+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin, ymax))+#
    theme_bw() + opts(legend.position="none")#
#
#
ymind  <- floor(   min(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
ymaxd  <- ceiling( max(c(asld$Difference, asfd$Difference),na.rm=T) /10)*10#
#ymax  <- ymax + 20#
ybred  <- seq(ymind, ymaxd, by=25)#
asld$data	<- factor(asld$data)#
p.dnld <- qplot(x=l2, y=Difference, data=subset(asld,corp=="Normal Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	colour=data, width=0.3,#
	main="       (Skip) -- (Non-Skip)")+#
	scale_colour_manual(  name="", values=c("grey","black"))+#
	scale_x_continuous(name="         Word Length [let]")+#
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position=c(0.1,0.02))#
p.dsld <- qplot(x=l2, y=Difference, data=subset(asld,corp=="Shuffled Text"),#
	geom=c("errorbar","line","point"),#
	ymin=Difference-se, ymax=Difference+se,#
	colour=data, width=0.3, #
	main="       (Skip) -- (Non-Skip)") + #
	scale_colour_manual(    name="", values=c("grey","black"), legend=FALSE) +#
	scale_linetype_manual(name="", values=c(4,2))+#
	scale_x_continuous(name="         Word Length [let]")+ #
	scale_y_continuous(name="Differences [ms]", breaks=ybred)+#
	coord_cartesian(ylim=c(ymind, ymaxd))+#
	geom_hline(y=0, colour="grey", linetype=2)+#
	theme_bw() + opts(legend.position="none")#
#
levels(asldC$corp)	<- c("Shuffled","Normal")#
levels(asldC$l2C)	<- c("short [2-6]","Middle Length\n[7-8]","long [9-10]")#
#
if (0) {#
#dev.off()#
quartz(width=3.5,height=3)#
print(  p.sub <- qplot(x=corp, y=Difference, fill=data, facets=.~l2C,#
	xlab="      ", ylab="", ymin=Difference-se, ymax=Difference+se,#
	data=subset(asldC,l2C!="Middle Length\n[7-8]"), geom=c("bar","errorbar"), position="dodge") + #
	geom_hline(yintercept=0) + scale_fill_grey(name="") + theme_bw() + #
	opts(legend.position=c(0.35,0.8))   )#c(0.7,1.1)#
ggsave(paste("skipsimple2mLc_SW_bar_",samp,".eps",sep=""))#
#
dev.off()#
quartz(width=9, height=6)#
pushViewport(viewport(layout = grid.layout(100, 100)))#
#
grid.text("Normal Text"  , 0.99, 0.75, gp=gpar(fontsize=14), rot=270)#
grid.text("Shuffled Text", 0.99, 0.25, gp=gpar(fontsize=14), rot=270)#
#
#
print(p.dnl , vp = viewport(layout.pos.row =  1: 50, layout.pos.col =  1: 33))#
print(p.anl , vp = viewport(layout.pos.row =  1: 50, layout.pos.col = 33: 65))#
print(p.dnld, vp = viewport(layout.pos.row =  1: 50, layout.pos.col = 65: 98))#
#
print(p.dsl , vp = viewport(layout.pos.row = 51:100, layout.pos.col =  1: 33))#
print(p.asl , vp = viewport(layout.pos.row = 51:100, layout.pos.col = 33: 65))#
print(p.dsld, vp = viewport(layout.pos.row = 51:100, layout.pos.col = 65: 98))#
#
#print(p.sub, vp = viewport(layout.pos.row = 55:82, layout.pos.col = 72:98))#
#
#
dev.copy2eps(file=paste("skipsimple2mLc_SW_",samp,"c.eps",sep=""))#
}#
#
#
#--------------------#
# use facet_grid()#
#--------------------#
asld$corp	<- factor(asld$corp, levels=levels(asld$corp)[2:1])#
# combine data#
pdat	<- rbind(asl, dsl)#
pdat$corp	<- factor(pdat$corp, levels=levels(pdat$corp)[2:1])#
pdat$s2F	<- factor(pdat$s2F)#
pdat$corp	<- factor(pdat$corp)#
pdat$max	<- pdat$dur_mean + pdat$dur_se#
pdat$min	<- pdat$dur_mean - pdat$dur_se#
pdat$dat2	<- pdat$data#
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), ##
#	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data) +facet_grid(corp~dat2) + # #
    geom_errorbar(aes(ymin= dur_mean - dur_se, ymax= dur_mean + dur_se), linetype=1, width=0.3)+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype( legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.3,0.85)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("line","point"),#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data) + facet_grid(corp~.) + # #
    geom_errorbar(aes(ymin=Difference-se, ymax=Difference+se),width=0.3, linetype=1)+#
    scale_linetype( name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 62))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 63:100))
#
# plot Exp + Sim#
pLeft <- qplot(l2, dur_mean, data=pdat, geom=c("line","point"), ##
#	ymin= dur_mean - dur_se, ymax= dur_mean + dur_se,#
    shape=s2F, linetype=data) +facet_grid(corp~dat2) + # #
    geom_errorbar(aes(ymin= dur_mean - dur_se, ymax= dur_mean + dur_se), linetype=1, width=0.3)+#
    scale_colour_manual(  name="", values="black")+ #
    scale_linetype_manual( value=c(2,1), legend=FALSE)+#
    scale_shape_manual(   name="", values=c(15,17))+ #, values=c(2,3), legend=FALSE#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Single Fixation Duration [ms]", breaks=ybre)+#
    coord_cartesian(ylim=c(ymin-5, ymax+5))+#
    theme_bw() + opts(legend.position=c(0.3,0.85)) # "none"#
#pLeft#
#
# plot Difference#
pRight <- qplot(l2, Difference, data=asld, geom=c("line","point"),#
	main="       (Skip) - (Non-Skip)", shape=1,#
    linetype=data) + facet_grid(corp~.) + # #
    geom_errorbar(aes(ymin=Difference-se, ymax=Difference+se),width=0.3, linetype=1)+#
    scale_linetype_manual( value=c(2,1), name="" )+ #name="", values=c(2,4))+ #, values=c(2,3), legend=FALSE#
    geom_hline(yintercept=0, linetype=2, colour="grey35")+#
    scale_x_continuous(name="         Word Length [let]")+ #
    scale_y_continuous(name="Difference [ms]", breaks=ybred)+#
    coord_cartesian(ylim=c(ymind, ymaxd))+#
    theme_bw() + opts(legend.position=c(0.45,0.45)) # "none"#
#pRight#
#
#
#
#dev.off()#
quartz(width=9*0.9, height=6*0.9)#
pushViewport(viewport(layout = grid.layout(1, 100)))#
print(pLeft , vp = viewport(layout.pos.row =  1, layout.pos.col =  1: 62))#
print(pRight, vp = viewport(layout.pos.row =  1, layout.pos.col = 63:100))
dev.copy2eps(file=paste("skipsimple2mLc_SW_",samp,"d.eps",sep=""))
source("xskipsimple2mLc.R")
