pdf("I:\\data\\ballistic1.pdf") ballistic1 <- read.fwf("I:\\data\\ballistic1.txt", width=c(8,8,8,8,8), col.names=c("bullettype","layers","v50","sharp","fsp")) attach(ballistic1) bullettype <- factor(bullettype) v50_sq <- (v50/100)^2 model1 <- lm(v50_sq ~ layers + sharp + fsp + I(layers*sharp) + I(layers*fsp)) summary(model1) anova(model1) model2 <- lm(v50_sq ~ layers + sharp + fsp) summary(model2) anova(model2) model3 <- lm(v50_sq ~ layers) summary(model3) anova(model3) anova(model1,model2) anova(model2,model3) xv <- seq(0,40,0.5) plot(layers,v50_sq,pch=as.numeric(bullettype),col=as.numeric(bullettype), xlab="Layers",ylab="V50^2", main="V50^2 versus Layers by Bullet Type") abline(lm(v50_sq ~ layers, subset=(bullettype==1)),lty=1,col=1) abline(lm(v50_sq ~ layers, subset=(bullettype==2)),lty=2,col=2) abline(lm(v50_sq ~ layers, subset=(bullettype==3)),lty=3,col=3) legend("topleft",c("Rounded","Sharp","FSP"),pch=c(1,2,3),col=c(1,2,3)) dev.off()