Jessica da Silva <jessica.m.dasilva <at> gmail.com> writes: > I am trying to create a scatterplot, coding each point to one of 5 > populations. I was successful when I did this for one set of data, yet > when I try plotting other data a blank plot appears (although the axes are > labelled and I can fit the regression lines from each population). I
However, once I add the command [grip$Morph] to > my symbol parameter (e.g., pch=c(2,6,5,19,15) [grip$morph] ), I loose all > the points. As I mentioned above, I was able to create a plot > successfully using other data points from the same table (different > columns), so I know the data are fine. > Try grip$morph<-unclass(grip$Morph) instead. Look at what as.character(factor(letters[1:3])) gives you. > R-script used: > ---------------------------------------- > HAND<-AllMal[,c(2,4,5)] > na.omit(HAND)->HAND > > write.csv(HAND, "grip.csv") > > read.csv("grip.csv")->grip > grip > class(grip) > class(HAND) > > grip$morph<-as.character(grip$Morph) > > morph<- grip$morph > BML<-grip$BML > grip$MCF->MCF > > reg1<-lm(BML~MCF,data=subset(grip,morph=="mel"));reg1 > reg2<-lm(BML~MCF,data=subset(grip,morph=="tham"));reg2 > reg3<-lm(BML~MCF,data=subset(grip,morph=="A"));reg3 > reg4<-lm(BML~MCF,data=subset(grip,morph=="B"));reg4 > reg5<-lm(BML~MCF,data=subset(grip,morph=="C"));reg5 > > plot(MCF,BML,pch=c(2,6,5,19,15)[grip$morph],xlab="Residual Metacarpal > Length",ylab="Residual Hand Strength (Broad Dowel)", main="Males") > abline(reg1,lty=1) > abline(reg2,lty=2) > abline(reg3,lty=3) > abline(reg4,lty=4) > abline(reg5,lty=6) > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.