Preparing the data

# Loading necessary libraries
library(ggplot2)
library(tidyr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
# Loading the dataset
library(readr)
Mustard <- read_csv("C:/Users/daniv/Downloads/Mustard.csv")
## Rows: 108 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): light, medium
## dbl (2): weight, watering
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Seeing the summary statistics

# Displaying summary statistics
summary(Mustard)
##      weight         light              watering    medium         
##  Min.   :0.060   Length:108         Min.   :1   Length:108        
##  1st Qu.:0.980   Class :character   1st Qu.:1   Class :character  
##  Median :1.780   Mode  :character   Median :3   Mode  :character  
##  Mean   :1.879                      Mean   :3                     
##  3rd Qu.:2.400                      3rd Qu.:5                     
##  Max.   :5.600                      Max.   :5                     
##  NA's   :3

Exploratory analysis

# Exploratory analysis for Growth Medium
ggplot(Mustard, aes(x = medium, y = weight)) +
  geom_boxplot() +
  labs(title = "Impact of Growth Medium on Mustard Yield",
       x = "Growth Medium",
       y = "Yield (grams)")
## Warning: Removed 3 rows containing non-finite values (`stat_boxplot()`).

# Exploratory analysis for Frequency of Watering
ggplot(Mustard, aes(x = watering, y = weight)) +
  geom_boxplot() +
  labs(title = "Impact of Watering Frequency on Mustard Yield",
       x = "Watering Frequency",
       y = "Yield (grams)")
## Warning: Continuous x aesthetic
## ℹ did you forget `aes(group = ...)`?
## Removed 3 rows containing non-finite values (`stat_boxplot()`).

# Exploratory analysis for Type of Light
ggplot(Mustard, aes(x = light, y = weight)) +
  geom_boxplot() +
  labs(title = "Impact of Light Type on Mustard Yield",
       x = "Light Type",
       y = "Yield (grams)")
## Warning: Removed 3 rows containing non-finite values (`stat_boxplot()`).

# ANOVA for Growth Medium
anova_growth_medium <- aov(weight ~ medium, data = Mustard)
summary(anova_growth_medium)
##              Df Sum Sq Mean Sq F value Pr(>F)    
## medium        3  85.48  28.494   41.16 <2e-16 ***
## Residuals   101  69.93   0.692                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 3 observations deleted due to missingness
# ANOVA for Watering Frequency
anova_watering <- aov(weight ~ watering, data = Mustard)
summary(anova_watering)
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## watering      1  38.76   38.76   34.22 5.87e-08 ***
## Residuals   103 116.66    1.13                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 3 observations deleted due to missingness
# ANOVA for Light Type
anova_light <- aov(weight ~ light, data = Mustard)
summary(anova_light)
##              Df Sum Sq Mean Sq F value Pr(>F)  
## light         2   7.76   3.878   2.679 0.0735 .
## Residuals   102 147.66   1.448                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 3 observations deleted due to missingness
# Extracting p-value from ANOVA summary
p_value <- anova(anova_growth_medium)[["Pr(>F)"]][1]

# Compare p-value to significance level (e.g., 0.05)
if (!is.null(p_value)) {
  if (p_value < 0.05) {
    cat("The ANOVA test indicates a statistically significant difference in mustard yield based on the growth medium (p-value =", p_value, ").\n")
  } else {
    cat("There is no significant difference in mustard yield based on the growth medium (p-value =", p_value, ").\n")
  }
} else {
  cat("Error: Unable to retrieve p-value from ANOVA summary.\n")
}
## The ANOVA test indicates a statistically significant difference in mustard yield based on the growth medium (p-value = 1.846048e-17 ).