Professional Documents
Culture Documents
Concole Output R.howes
Concole Output R.howes
> library(dplyr)
> library(readxl)
> library(car) # For ANOVA
>
> # Load the dataset
> data <- read_excel("mould_growth_experiment.xlsx")
>
> # Check the structure of the data
> str(data)
tibble [280 × 5] (S3: tbl_df/tbl/data.frame)
$ Bread_Type : chr [1:280] "Wholegrain" "White" "Wholegrain" "White" ...
$ Condition : chr [1:280] "Dry" "Dry" "Moist" "Moist" ...
$ Replicate : num [1:280] 1 1 1 1 2 2 2 2 3 3 ...
$ Day : num [1:280] 1 1 1 1 1 1 1 1 1 1 ...
$ Mould_Growth: num [1:280] 89.7 26.6 37.2 57.3 90.8 ...
>
> # Convert relevant columns to factors
> data <- data %>%
+ mutate(
+ Bread_Type = factor(Bread_Type),
+ Condition = factor(Condition),
+ Replicate = factor(Replicate),
+ Day = as.numeric(Day)
+ )
>
> # Two-way ANOVA
> anova_results <- aov(Mould_Growth ~ Bread_Type * Condition, data = data)
> summary(anova_results)
Df Sum Sq Mean Sq F value Pr(>F)
Bread_Type 1 690 689.7 0.940 0.333
Condition 1 296 295.8 0.403 0.526
Bread_Type:Condition 1 55 54.8 0.075 0.785
Residuals 276 202574 734.0
>
> # Interpretation:
> # - Significant main effects of Bread_Type and Condition indicate that
these factors independently affect mould growth.
> # - A significant interaction effect (Bread_Type:Condition) would suggest
that the effect of one factor depends on the level of the other factor.
>
> # Pairwise t-tests for Bread Type
> pairwise_t_bread <- pairwise.t.test(data$Mould_Growth, data$Bread_Type,
p.adjust.method = "bonferroni")
> pairwise_t_bread
White
Wholegrain 0.33
Dry
Moist 0.53
>