Advertisement
897bhgy

Untitled

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