############################## # # 20110208-wheat3.R # ############################## # # This file shows you how I created the wheat3 dataset using R. # # Set the random number seed so I can replicate my results set.seed(7) ppp <- 5 # Define the variable road as the position of the plot of land with respect to the road. road <- c( rep("A",3*ppp),rep("B",3*ppp),rep("C",3*ppp) ) # Define the variable fertilizer to specify which type of fertilizer we used on each plot fertilizer <- rep( c("N18P51K20","N13P00K44","N18P18K18"),3*ppp ) # Create a dependence between the expected wheat height and the plot position and the fertilizer used m <- 100 + (fertilizer=="N18P51K20")*10 - (fertilizer=="N18P18K18")*10 - (road=="A")*25 - (road=="B")*10 # Create a constant standard deviation s <- 3 # Create the height variable height <- floor( rnorm(length(m), m, s) ) # Put the four variables together into one dataframe wheat3 <- data.frame(species="Triticum polonicum", fertilizer=fertilizer, strip=road, height=height) # Write this data to a csv file write.csv(wheat3, "wheat3.csv", row.names=FALSE)