I use RStudio to calculate an analysis of variance (ANOVA). I use the aov function on a csv file you can find at the bottom of this post. This is my code:
filename = 'testdata.csv'
# Read in csv`
testdata <- read_csv(filename)
# add id`
testdata$id <- seq(nrow(testdata))
# Convert table to fit aov prerequisites
testdata <- testdata %>%
gather(key = "time", value = "amplitude", c1, c2, c3)
# define factor
testdata$time <- as.factor(testdata$time)
# calculate ANOVA
res.aov <- aov(amplitude~factor(time)+Error(factor(id)), data = testdata)
summary(res.aov)
# use eta_sq
eta1 = eta_sq(res.aov)
# use eta_squared as eta_sq is deprecated
eta2 = eta_squared(res.aov)
When I execute this code, I get the following error message:
Error in UseMethod("anova") :
no applicable method for 'anova' applied to an object of class "c('aovlist', 'listof')"
I am not sure what that means. Any idea how to solve this?
Thanks,
Fred
CSV file:
c1,c2,c3
-0.56,-0.22,1.68
-1.71,-2.91,1.59
-0.75,-0.54,-2.52
0.47,0.45,1.16
0.68,0.78,-0.16
-1.02,-0.62,-3.26
-1.53,-0.04,-1.62
-0.35,0.17,0.32
-0.39,1.83,-0.6
2.22,2.32,0.15
0.2,-0.06,-1.13
-1.51,0.98,-2.36
-2.75,-1.09,-0.42
-0.07,-0.29,-0.67
-0.93,-0.03,-0.9
-1.06,0.09,-1.34
-2.02,-1.11,-3.47
-3.54,-3.3,-4.09
-1.71,-1.97,-2.93
-0.22,-0.36,-1.47
-1.63,0.7,-0.57
-1.24,-0.87,-2.16
-0.42,0.54,-1.06
-0.33,-0.03,-0.98
0.34,0.47,-0.4
1.12,1.25,0.13
0.09,0.64,0.25