# 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.
# 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 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()`).
The boxplot reveals significant disparities in mustard yield across diverse growth media. Specifically, soil and cotton wool exhibit higher median yields, contrasting with lower yields in newspaper and sawdust. Outliers underscore unique responses to specific growth media, emphasizing the substantial impact of medium selection on mustard yield.
# 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 = ...)`?
## Warning: Removed 3 rows containing non-finite values (`stat_boxplot()`).
The boxplot demonstrates a distinct correlation between watering frequency and mustard yield. As the frequency rises from 1 to 5 times over 14 days, a discernible trend of elevated median yields becomes apparent. Outliers indicate variations in plant responses to varying watering schedules, underscoring the significance of frequency in shaping mustard yield.
# 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()`).
The boxplot suggests potential differences in mustard yield across various light types. Although some variations may exist, the overall influence of light type seems less prominent when compared to other factors. Outliers imply distinctive responses in certain mustard plants to specific light types, yet additional research is necessary to validate the significance of these differences.
# 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 ).
The FIRST ANOVA results suggest a highly significant difference in mustard yield based on the growth medium (p < 0.001). The F-statistic of 41.16 indicates substantial variability among the group means compared to within-group variability. Given the low p-value, you would reject the null hypothesis and conclude that the choice of growth medium has a significant impact on mustard yield. These results support the idea that the growth medium significantly influences mustard yield.
The ANOVA results suggest a highly significant difference in mustard yield based on watering frequency (p < 0.001). The F-statistic of 34.22 indicates substantial variability among the group means compared to within-group variability. Given the low p-value, you would reject the null hypothesis and conclude that the watering frequency has a significant impact on mustard yield. These results support the idea that the watering frequency significantly influences mustard yield.
The ANOVA results for the type of light suggest that there is not enough evidence to reject the null hypothesis at the 0.05 significance level (p = 0.0735). The F-statistic of 2.679 indicates some variability among the group means, but this result is not statistically significant. In this case, you would fail to reject the null hypothesis, suggesting that the type of light may not have a significant impact on mustard yield.
The ANOVA test strongly supports the conclusion that the growth medium significantly influences mustard yield.