(Reading time 6 min.) Click here for Data set R-script #Fitting of linear model model <-lm(CRD$Yield ~ CRD$Treatment) #Obtains R Square and other statistics of fitted model summary <-summary(model) #Carryout ANOVA anova <-anova(model) anova #Below codes are used to obtain plots of fitted vs Residuals and Normal QQ plots par(mfrow=c(1,2)) plot(model, which=1) plot(model, which=2) #Load the package library(agricolae) #Carry out LSD test LSD <-LSD.test(CRD$Yield,CRD$Treatment,anova$`Df`[2],anova$`Mean Sq`[2]) #Generate the txt file of analysis sink("crdanalysis.txt") print("ANOVA of CRD") print(anova) print("LSD ANALYSIS") print(LSD$statistics) print(LSD$groups) sink() Output [1] "ANOVA of CRD" Analysis of Variance Table Response: CRD$Yield Df Sum Sq Mean Sq F value Pr(>F) CRD$Treatment 1 220.90
Comments
Post a Comment