shortdata <- data.frame(X=c(5,4,1,2),Y=c(10,8,1,3),Z=c('A','A','B','B')) attach(shortdata) # 2/ plot(X,Y,col=Z,xlab='X',ylab='Y',lwd=2) points(x=4,y=6,'p',col='blue',lwd=2) text(x=4.2,y=6,labels=c('?'),col='blue',cex=1,lwd=2) scan('') # 3/ dlogrule <- glm(Z~X+Y,data=shortdata,family=binomial(lin='logit')) print(summary(dlogrule)) # 4/ print(predict(dlogrule,new=data.frame(X=4,Y=6))) # 4/ plot(X,Y,col=Z,xlab='X',ylab='Y',lwd=2) abline(-dlogrule$coefficients[[1]]/dlogrule$coefficients[[3]],-dlogrule$coefficients[[2]]/dlogrule$coefficients[[3]],col='red') points(4,6,col='red',lwd=2)