How can I subset variables from one column to use in an ANOVA r?

Viewed 28

I have the follow test data:

df <- data.frame(Type = c('A','A','A','B','B','B','C','C','C','D','D','D') ,
                 Value = c('4','0','5','5','1','4','4','3','9','1','0','2'))

I'd like to run an ANOVA for the interaction between Type "A" and Type "C".

The basic model would look like:

aov(Value ~ A * C , data = df)

Is there a simple subset function I can use that will only select the values from Type "A" and Type "C"?

1 Answers

We could use

broom::tidy(aov(Value ~ Type, subset(df, Type %in% c("A", "C"))))
Related