#read the table and create a screen to plot #divided in 2*2 spaces # here's how to read in the data under Unix fish_read.table("fish.asc",header=T) motif() par(mfrow=c(2,2)) # first two histograms hist(fish$conc,xlab="Concentration ppm", ylab="Count",main="Mercury\nconcentrations") fish$logconc_log(fish$conc,base=10) hist(fish$logconc,xlab="log concentration ppm", ylab="Count",main="Log Mercury concentrations") # boxplots # split the boxplot to have two in the same graph # use split(vble,vble) into the boxplot command boxplot(split(fish$logconc,fish$river), ylab="log concentration ppm",xlab="river", main="concentration by river") boxplot(split(fish$logconc,fish$station), ylab="log concentration ppm",xlab="station", main="Concentration by station") # length and width with identification of outliers plot(fish$length,fish$weight,xlab="length in cm", ylab="length in gm",main="Fish size",pch=1) # click on the graph to put an identification # number to the data. Don't forget to click the # middle button of your mouse to quit. identify(fish$length,fish$weight,fish$station) # plot of length and weight using station number as # plotting symbol plot(fish$length,fish$weight,xlab="length in cm",pch=1, type="n",ylab="length in gm",main="fish size by station") # Make the symbols .7 times as their regular size using # cex in the text command. text(fish$length,fish$weight,fish$station,cex=.7) plot(fish$weight,fish$logconc,xlab="weight in gm", ylab="log concentration ppm",pch=1, main="Log concentration by weight") # If you'd rather use a different plotting symbol, # here's a way to do that. plot(fish$length,fish$weight,xlab="length in cm",pch=1, type="n",ylab="length in gm",main="fish size by station") for(i in 1:16) points(fish$length[fish$station==i], fish$weight[fish$station==i],pch=i) # if you want to see what plotting symbols are available # here's a way to do it: plot(c(0,21),c(0,3),type="n") for(i in 1:20){ points(i,1,pch=i) text(i,2,i) } text(10,2.3,"pch number",cex=1.2) text(10,1.3,"plotting symbol",cex=1.2) # Weight by logconc. I'll use different plotting symbols # and a legend rivernum_ifelse(fish$river=="wacamaw",1,2) plot(fish$weight,fish$logconc,xlab="length in cm",pch=1, type="n",ylab="log concentration (ppm)",main="weight by mercury conc") for(i in 1:2) points(fish$weight[rivernum==i], fish$logconc[rivernum==i],pch=i) legend(2800,-0.6,legend=c("Wacamaw R","Lumber R"),marks=c(1,2),cex=.8) # the first two entries give the x,y coordintates of the # upper-left of the legend box; for more info type: ?legend # Now, length by logconc plot(fish$length,fish$logconc,xlab="length in cm",pch=1, type="n",ylab="log concentration (ppm)",main="length by mercury conc") for(i in 1:2) points(fish$length[rivernum==i], fish$logconc[rivernum==i],pch=i) legend(48,-0.6,legend=c("Wacamaw R","Lumber R"),marks=c(1,2),cex=.8) par(mfrow=c(1,1)) # take columns 3,4 and 6 (logconc) and graph them together pairs(fish[,c(3,4,6)]) # That's it.