############################## # # Create the wheat2 dataset # # Filename: 20110201-wheat2.R # ############################## # This file shows you how I created the wheat2 dataset # using R. # Set the random number seed so I can replicate my results set.seed(370) # Create the heights of the wheat in each plot p1 <- floor(rnorm(12, m=36, s=4)) # Plot A1 p2 <- floor(rnorm(12, m=36, s=4)) # Plot A2 p3 <- floor(rnorm(12, m=36, s=4)) # Plot A3 p4 <- floor(rnorm(12, m=30, s=4)) # Plot B1 p5 <- floor(rnorm(12, m=30, s=4)) # Plot B2 p6 <- floor(rnorm(12, m=30, s=4)) # Plot B3 p7 <- floor(rnorm(12, m=20, s=4)) # Plot C1 p8 <- floor(rnorm(12, m=20, s=4)) # Plot C2 p9 <- floor(rnorm(12, m=20, s=4)) # Plot C3 # Create a vector of plot identifiers plot <- c( rep("A1", 12), rep("A2", 12), rep("A3", 12), rep("B1", 12), rep("B2", 12), rep("B3", 12), rep("C1", 12), rep("C2", 12), rep("C3", 12) ) # Create a vector of fertilizer identifiers fertilizer <- c( rep("N18P51K20",36),rep("N13P00K44",36),rep("N18P18K18",36) ) # Create the vector of wheat heights from the random numbers above height <- c(p1,p2,p3,p4,p5,p6,p7,p8,p9) # Put all of these into one dataframe, with the species name data <- data.frame(species="Triticum spelta", plot=as.factor(plot), fertilizer=fertilizer, height=height) # Write this dataframe to a csv file write.csv(data,"wheat2.csv", row.names=FALSE)