# R help for question 9 in Topic 8 # first we read in the dataset iris.txt # variables are Species, SpecCode, SepLen, SepWd, PetLen, PetWd, LD data=read.table("http://bayes.bgsu.edu/m400/data/iris1.txt", header=T,sep="\t") # here's a plot of sepal length against width for two species of iris attach(data) plot(SepWd[Species=="Setosa"],SepLen[Species=="Setosa"], xlim=c(1.8,4.2),ylim=c(4,7.2),xlab="SepWd",ylab="SepLen") points(SepWd[Species=="Versicolor"],SepLen[Species=="Versicolor"],pch=19) legend("topright",legend=c("Setosa","Versicolor"),pch=c(1,19)) # I'm adding a line with interecept .877 and slope 1.477 to the # current graph -- this corresponds to the linear discrimintor. abline(a=.877,b=1.477) # Maybe a more direct way to see the separation is to compute # values of LD and construct a dotplot of LD against species. LD= 0.877 - SepLen + 1.477 * SepWd stripchart(LD ~ Species,pch=19,method="stack")