# Load necessary libraries library(tidyverse) library(ggfortify) # For PCA visualization # Load a sample dataset data(iris) # Perform a t-test (comparing setosa and versicolor petal lengths) t_test <- t.test(iris$Petal.Length[iris$Species == "setosa"], iris$Petal.Length[iris$Species == "versicolor"]) print(t_test) # Interpretation of t-test results: # - The p-value indicates whether there is a significant difference in petal lengths # between the two species. A p-value < 0.05 suggests a statistically significant difference. # - The confidence interval provides a range for the true difference in means. # Chi-squared Test # Create a contingency table table_data <- table(iris$Species, iris$Sepal.Length > 5.5) chisq_test <- chisq.test(table_data) print(chisq_test) # Interpretation of Chi-squared results: # - A significant p-value (< 0.05) indicates an association between # the variables. # ANOVA Test anova_result <- aov(Sepal.Length ~ Species, data = iris) summary(anova_result) # Interpretation of ANOVA results: # - Tests whether the mean of Sepal.Length differs significantly across species. # - A significant p-value (< 0.05) suggests at least one group mean is different.