library(ggplot2) #ggplot2 makes the distribution curve graphs library(car) #not sure what car does but I think it works with lattices library(splitstackshape) #splitstackshape is an easy package that can help you split columns that have delimiters, #Original CSV file column labelled "Tray" had entries that needed to be split picsize5=read.csv('ImageJsize4.csv') #creates dataframe and reads in the CSV file for sizes picsize6<-concat.split.multiple(picsize5, "Tray", " ") #splits the Tray column into Tray_1 with Site Number and Tray_2 with Tray number foys<-subset(picsize6, Date=="2/26/2014"& Site=="Oyster Bay") #creates a subset data frame for just the size data from February 26th at Oyster Bay ggplot(foys, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3) #creates distribution graph overlays for all populations in Feb at Oyster Bay. Looks cool. fman<-subset(picsize6, Date=="2/26/2014"& Site=="Manchester") ggplot(fman, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3) ffid<-subset(picsize6, Date=="2/28/2014"&Site=="Fidalgo") ggplot(ffid, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3) #ffid and fman are just repeating the same subset dataframe command #and then creating distribution overlay graphs for each site picsize7=read.csv('imagejsizefixed1.csv') picsize8<-concat.split.multiple(picsize7, "Tray", " ") endoys<-subset(picsize8, Date %in% c("7/24/2014", "7/31/2014","8/7/2014","8/14/2014")) ggplot(endoys, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3) endfid<-subset(picsize8, Date %in% c("7/25/2014","8/1/2014","8/8/2014","8/15/2014")) ggplot(endfid, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+scale_colour_fill(values=c("#3366CC","#CC66CC","#FF9900")) fidn<-subset(picsize8, Site %in% c("Fidalgo","fidalgo")& Tray_1=="2N") ggplot(fidn, aes(x=Length.mm))+geom_density(aes(group=Date, colour=Date),alpha=0.3) fidsize<-subset(picsize8, Site %in% c("Fidalgo","fidalgo")) ggplot(fidsize, aes(x=Length.mm))+geom_density(aes(group=Date, colour=Date),alpha=0.3)+facet_wrap(~Tray_1, ncol=1) ggplot(mansize, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1),alpha=0.3)+facet_wrap(~Date, ncol=3)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+scale_fill_manual(values=c("#3366CC","#CC66CC","#FF9900")) endman<-subset(picsize6, Date == "7/23/2014"| Date == "7/30/2014"| Date=="8/6/2014"|Date=="8/13/2014") ggplot(endman, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+scale_fill_manual(values=c("#3366CC","#CC66CC","#FF9900"))+ggtitle('End of Summer\nManchester Size Distribution') endoys<-subset(picsize6, Date %in% c("7/24/2014", "7/31/2014","8/7/2014","8/14/2014")) ggplot(endoys, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+scale_fill_manual(values=c("#3366CC","#CC66CC","#FF9900"))+ggtitle('End of Summer\nOyster Bay Size Distribution') endfid<-subset(picsize6, Date %in% c("7/25/2014","8/1/2014","8/8/2014","8/15/2014")) ggplot(endfid, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3)+scale_colour_manual(values=cou)+scale_fill_manual(values=c("#3366CC","#CC66CC","#FF9900"))+ggtitle('End of Summer\nFidalgo Size Distribution') ggplot(fidsize, aes(x=Length.mm))+geom_density(aes(group=Date, colour=Date),alpha=0.3)+facet_wrap(~Tray_1, ncol=1) ggplot(fidsize, aes(x=Length.mm))+geom_density(aes(group=Date, colour=Date, fill=Tray_1),alpha=0.3)+facet_wrap(~Tray_1, ncol=1) ggplot(fidsize, aes(x=Length.mm))+geom_density(aes(group=Date, colour=Date),alpha=0.3)+facet_wrap(~Tray_1, ncol=1) mansize<-subset(picsize8, Site %in% c("Manchester","manchester")) ggplot(mansize, aes(x=Length.mm))+geom_density(aes(group=Date, colour=Date),alpha=0.3)+facet_wrap(~Tray_1, ncol=1) oyssize<-subset(picsize8, Site %in% c("Oyster Bay","oyster bay")) ggplot(oyssize, aes(x=Length.mm))+geom_density(aes(group=Date, colour=Date),alpha=0.3)+facet_wrap(~Tray_1, ncol=1) ggplot(mansize, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1),alpha=0.3)+facet_wrap(~Date, ncol=3)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+scale_fill_manual(values=c("#3366CC","#CC66CC","#FF9900")) ggplot(oyssize, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1),alpha=0.3)+facet_wrap(~Date, ncol=3)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+scale_fill_manual(values=c("#3366CC","#CC66CC","#FF9900")) oyssize<-subset(picsize8, Site %in% c("Oyster Bay","oyster bay", "Oyster bay")) ggplot(oyssize, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1),alpha=0.3)+facet_wrap(~Date, ncol=3)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+scale_fill_manual(values=c("#3366CC","#CC66CC","#FF9900")) ggplot(fidsize, aes(x=Length.mm))+geom_density(aes(group=Tray_1, colour=Tray_1),alpha=0.3)+facet_wrap(~Date, ncol=3)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+scale_fill_manual(values=c("#3366CC","#CC66CC","#FF9900")) outoys<-subset(outplant1, Site=="Oyster Bay") ggplot(outoys, aes(x=Size))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+scale_fill_manual(values=c("#3366CC","#CC66CC","#FF9900"))+ggtitle("Outplant\nOyster Bay Size Distribution")+labs(x="Length.mm") outfid<-subset(outplant1, Site=="Fidalgo") ggplot(outfid, aes(x=Size))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+scale_fill_manual(values=c("#3366CC","#CC66CC","#FF9900"))+ggtitle("Outplant\nFidalgo Size Distribution")+labs(x="Length.mm") outman<-subset(outplant1, Site=="Manchester") ggplot(outman, aes(x=Size))+geom_density(aes(group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+scale_fill_manual(values=c("#3366CC","#CC66CC","#FF9900"))+ggtitle("Outplant\nManchester Size Distribution")+labs(x="Length.mm") outendoys<-merge(endoys, outoys, by="Site") ggplot(aes(endoys,x=Length.mm)+(outoys,x=Size))+geom_density(aes(group=Tray_1, colour=Tray_1),alpha=0.3)+facet_wrap(~Tray_1, ncol=1)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+scale_fill_manual(values=c("#3366CC","#CC66CC","#FF9900")) ggplot()+geom_density(data=outoys, aes(x=Length.mm, group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3)+geom_density(data=endoys, aes(x=Length.mm, group=Tray_1, colour=Tray_1, fill=Tray_1),alpha=0.3)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900"))+scale_fill_manual(values=c("#3366CC","#CC66CC","#FF9900"))+ggtitle("Size Comparison\nAugust 2013 vs. August 2014") ggplot(mansize, aes(Date,Length.mm, group=Tray_1, color=Tray_1))+geom_point()+geom_smooth(method=lm)+scale_colour_manual(values=c("#3366CC","#CC66CC","#FF9900")) endoys$Date<-as.Date(endoys$Date, "%m/%d/%Y") outoys$Date<-as.Date(outoys$Date, "%m/%d/%Y") mansize$Date<-as.Date(mansize$Date, "%m/%d/%Y")