This is an R HTML document. When you click the Knit HTML button a web page will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
You can also embed plots, for example:
y <- c(12,14,13,15,16, 18,17,19,20,18, 10,11,9,12,8) g <- factor(rep(c(“G1”,“G2”,“G3”), each = 5))
anova_model <- aov(y ~ g)
summary(anova_model)
tukey_result <- TukeyHSD(anova_model)
tukey_result
plot(tukey_result) # Given data y <- c(5,6,7,8, 6,7,8,9, 10,11,12,13) A <- factor(rep(c(“A1”,“A2”,“A3”), each = 4)) B <- factor(rep(c(“B1”,“B2”), times = 6))
model <- aov(y ~ A + B)
summary(model)
anova_summary <- summary(model) p_value_A <- anova_summary[[1]][“A”, “Pr(>F)”]
p_value_B <- anova_summary[[1]][“B”, “Pr(>F)”]
p_value_A p_value_B # Given data y <- c(11,13,12,14, 15,17,16,18, 20,22,21,23) A <- factor(rep(c(“A1”,“A2”,“A3”), each = 4)) B <- factor(rep(c(“B1”,“B2”), times = 6))
model <- aov(y ~ A * B)
summary(model)
anova_summary <- summary(model) p_value_interaction <- anova_summary[[1]][“A:B”, “Pr(>F)”]
p_value_interaction # Draw interaction plot interaction.plot(x.factor = B, trace.factor = A, response = y, type = “b”, col = c(“red”, “blue”, “green”), pch = 16, xlab = “Factor B”, ylab = “Mean of y”, trace.label = “Factor A”)