zz <- file.path("U:","My Documents")

#File.Location <- file.path(zz,"BALANCED.sav")
File.Location <- file.path(zz,"BALANCED.csv")
library(foreign)
y <- read.csv(File.Location)
y <- data.frame(y)
attach(y)
regout <- lm(score ~ task*group,data=y)
regout <- lm(score ~ as.factor(task)*as.factor(group),data=y)
anova(regout)

# group means

#install.packages("plyr")
library(plyr)
ddply(y,.(group),summarise,mean=mean(score),sd=sd(score))

# unpacking interactions as simple effects

#install.packages("emmeans")
library(emmeans)
emcatcat <- emmeans(regout, ~ task*group, data=y)
contrast(emcatcat, "revpairwise",by="group",adjust="none")
emcatcat

model <- aov(score~as.factor(group), data=y)
summary(model)
TukeyHSD(model, conf.level=.95)

mdat <- y[y$group==1,]
model <- aov(score~as.factor(task), data=mdat)
summary(model)
TukeyHSD(model, conf.level=.95)

# below output confusing so just use above Tukey for each separate group

model <- aov(score~as.factor(group)*as.factor(task), data=y)
summary(model)
TukeyHSD(model, conf.level=.95)
