I have this data in r, which I need to make an anova with.
My problem is, that I only need data out of Faktor
0 and 2 but not 1.
I can access one with:
FSQ$total_Sum[FSQ$Faktor=="0"]
but I don;t know how I can create an anova with only Faktor 0,2. Here is my current anova code:
anova_FSQ_Vor_Nach <- aov(FSQ$Faktor ~FSQ$total_Sum[FSQ$Faktor=="0"])
thanks for the help.
CodePudding user response:
We may use subset
for this.
# option 1
aov(Faktor ~ total_Sum, data = subset(FSQ, Faktor %in% c(0,2)))
# option 2
with(subset(FSQ, Faktor %in% c(0,2)), aov(Faktor ~ total_Sum))
Output
Call:
aov(formula = Faktor ~ total_Sum)
Terms:
total_Sum Residuals
Sum of Squares 0 8
Deg. of Freedom 1 6
Residual standard error: 1.154701
Estimated effects may be unbalanced
Data
FSQ <- data.frame(
Faktor = rep(c(0,1,2), 4L),
total_Sum = c(4,23,4,0,0,0,3,3,7,4,0,0)
)
CodePudding user response:
You could create a new dataframe containing only rows where Faktor equals 0 or 2:
newFSQ <- FSQ[Faktor == 0 | Faktor == 2,]
aov(newFSQ$Faktor ~ newFSQ$total_Sum)