I have a data structure organized as in next image (two populations and some parameters). I'm getting confused with coding. Which is the way to make an ANOVA test that drops the suitability (F, p value) of each parameter, please?
Asked
Active
Viewed 569 times
1 Answers
1
You could try something like this, but probably need to account for multiple comparisons:
library(data.table)
DT <- data.table("GROUP" = c("GR1", "GR1", "GR1", "GR2", "GR2")
, "Weight" = c(78, 85, 84.3, 70, 67)
, "BloodPres" = c(11, 14, 13, 12, 12)
, "Heart" = c(140, 130, 142, 135, 120)
, "Glucose" = c(80, 110, 95, 97, 105))
Outcomes <- c("Weight", "BloodPres", "Heart", "Glucose")
sapply(Outcomes, function(my) {
f <- as.formula(paste(my, "~GROUP", sep=""))
summary(aov(f, data=DT))
})
This works for one-way, but you'll need to adjust it for two-way (see Correct use of sapply with Anova on multiple subsets in R).

cgrafe
- 443
- 1
- 6
- 14
-
1Thanks. I found this https://www.educba.com/anova-in-r/ interesting. At the end of the page, it compares response, vs treatment & BP, similar case to mine – galtor Mar 23 '20 at 15:09