#Remove objects from prior sessions rm(list=ls()) #make sure the working directory is correct getwd() setwd("C:/Users/aamahama/Desktop/") #Next load in the data set from a spreadsheet (.csv) ds1<-read.csv("ds 1.csv",header=T) #look at some of the data to make sure it is read into R properly ds1[1:10,] ds1[26:35,] attach(ds1) summary(ds1) ds1$entry<-factor(ds1$entry) ds1$env<-factor(ds1$env) ds1$blk<-factor(ds1$blk) summary(ds1) detach(ds1) mean(yld) sd(yld) # conduct some exploratory data analyses # histogram of the yield data hist(ds1$yld) hist(ds1$yld,col="beige",main="Frequency of Yield Across Locations",xlab="Yield") #Try a boxplots to look at distributions of each environment boxplot(ds1$yld~ds1$env,main="Boxplot by Environment",xlab="Environment",ylab="Yield") boxplot(ds1$yld~ds1$entry,main="Boxplot by Entry",xlab="Entry",ylab="Yield") boxplot(ds1$yld~ds1$blk,main="Boxplot by Block",xlab="Block",ylab="Yield") # consider analysis of variance: What is the model? # linear model: y=mean+env+blk(env)+ent: What about GxE? anova(lm(yld~env+entry)) aov<-(anova(lm(yld~env+env/blk+entry))) #generate lsmeans library(lsmeans) lsm<-(lm(yld~env+entry)) lsmeans(lsm,~entry) sink("EDA _AOV_ds1.txt") aov lsmeans(lsm,~entry) sink()