Generation

generate functionMon, 20 Mar 2023

A large agricultural company produces two species of grass and would like to know which type to grow in Northern Ontario. They would also like to know which of their three fertilizers is most effective for that grass. The company conducts an experiment in a large patch of soil in Northern Ontario. The patch is divided into 30 regions, and 5 are randomly selected for each grass/fertilizer combination. After several months, you determine the number of blades of grass per square inch in each region. The data is given in the file “Grass.csv”. HINT: type of species and type of fertilizer are given as numerical values and you must convert them to categories. What type of experiment is this?

# Read the data grass = read.csv("Grass.csv") names(grass) = c("grass", "fertilizer", "blades") head(grass) # Convert the factors to levels grass$grass_lev = factor(grass$grass, labels = c("1", "2")) grass$fertilizer_lev = factor(grass$fertilizer, labels = c("1", "2", "3")) # Create interaction variable grass$grass_fer_int = interaction(grass$grass_lev, grass$fertilizer_lev) # Display head of data head(grass) # Create side-by-side boxplot boxplot(blades ~ grass_fer_int, data = grass, xlab = "Grass species and Fertilizer", ylab = "Number of blades") # Create boxplot with the same x-axis boxplot(blades ~ grass_lev + fertilizer_lev, data = grass, xlab = "Grass species and Fertilizer", ylab = "Number of blades")

Questions about programming?Chat with your personal AI assistant