Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Set a seed for reproducibility of results
- set.seed(123)
- # Simulate the heights of plants grown under low, medium, and high light conditions
- low_light <- rnorm(30, mean = 15, sd = 2) # 30 plants under low light
- medium_light <- rnorm(30, mean = 20, sd = 3) # 30 plants under medium light
- high_light <- rnorm(30, mean = 25, sd = 4) # 30 plants under high light
- # Create a dataframe combining the heights and corresponding light conditions
- df <- data.frame(
- height = c(low_light, medium_light, high_light),
- light = factor(rep(c("Low", "Medium", "High"), each = 30)) # light conditions
- )
- # Null Hypothesis (H0): The mean heights of plants grown under low, medium, and high light conditions are equal.
- # Alternative Hypothesis (H1): At least one group's mean height is different from the others.
- # Perform an Analysis of Variance (ANOVA) test to check if light conditions affect plant height
- result <- aov(height ~ light, data = df) # height is the dependent variable, light is the independent variable
- # Print the results of the ANOVA test, which include the F-statistic and the p-value
- # If p-value < 0.05, we reject the null hypothesis and conclude that there's a significant difference in mean heights.
- # If p-value > 0.05, we fail to reject the null hypothesis and conclude that there's not enough evidence of a significant difference.
- summary(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement