{
    "contents" : "#Name: Jake Heare\n# Assigment 3\n\n#Q1\n#q1a\nrequire(scales)\nrequire(plyr)\nmack.black<-read.table(\"http://ram.biology.dal.ca/ftp/pub/sr/MACKBLACK.dat\",\n                       sep=\"\",na.strings=\"NA\",dec=\".\",strip.white=T)\nmack.nafo<-read.table(\"http://ram.biology.dal.ca/ftp/pub/sr/MACK2-6.dat\",\n                      sep=\"\",na.strings=\"NA\",dec=\".\",strip.white=T)\nmack.ices<-read.table(\"http://ram.biology.dal.ca/ftp/pub/sr/MACKWS.dat\",\n                      sep=\"\",na.strings=\"NA\",dec=\".\",strip.white=T)\nmack.black<-rename(mack.black, c('V1'='Year',\"V2\"=\"spawners\",\n                                 'V3'='recruits','V4'='catch','V5'='fishMortality'))\nmack.nafo<-rename(mack.nafo, c('V1'='Year',\"V2\"=\"spawners\",\n                                 'V3'='recruits','V4'='catch','V5'='fishMortality'))\nmack.ices<-rename(mack.ices, c('V1'='Year',\"V2\"=\"spawners\",\n                                 'V3'='recruits','V4'='catch','V5'='fishMortality'))\n#q1b\nmack.partial<-merge(mack.black, mack.nafo, by=\"Year\",\n                    suffixes=c('.black','.nafo'), incomparables=NA)\n#q1c\nmack<-merge(mack.partial,mack.ices,by=\"Year\", incomparables=NA)\n#1qd\nmack<-rename(mack, c('spawners.black'='spawners.black','recruits.black'='recruits.black',\n                     'catch.black'='catch.black','fishMortality.black'='fishMortality.black',\n                     'spawners.nafo'='spawners.nafo','recruits.nafo'='recruits.nafo',\t\n                     'catch.nafo'='catch.nafo','fishMortality.nafo'='fishMortality.nafo',\n                     'spawners'='spawners.ices','recruits'='recruits.ices',\n                     'catch'='catch.ices','fishMortality=fishMortality.ices'))\nmack$fishMortality.ices<-mack$fishMortality\nmack$fishMortality<-NULL\n#q1e\nrequire(ggplot2)\nmack$Year<-as.Date(mack$Year,\"%Y\")\nmack[mack==\".\"]<-NA\nplot(mack$Year,mack$spawners.nafo, type='l',lty=2,col=\"red\", ylim=c(0,3500),\n     xlab=\"Years\",ylab=\"Spawner Biomass (thousands of tons)\")\nlines(mack$Year,mack$spawners.black, type='l',lty=2,col=\"black\")\nlines(mack$Year,mack$spawners.ices, type='l',lty=2, col=\"green\")\ntitle(main=\"Atlantic Mackeral\")\n#I can't figure out why the lines function is ignoring the y axis values of the other two data sets. \n#Q2\n#q2a\nx<-seq(as.Date(\"2010-1-1\"),as.Date(\"2010-6-30\"), by=\"day\")\nmonths<-months(x)\nn<-c(40,42,51,55,58,62)\ntempdata<-rnorm(n=months, mean=n, sd=5)\ntemperature<-data.frame(as.Date(x),tempdata)\n#q2b\nrequire(plyr)\ntemperature$as.Date.x.<-as.Date(temperature$as.Date.x.)\ntemperature$month<-months(temperature$as.Date.x.)\nMeanmonthtemp<-ddply(temperature,.(month),summarise,mean_temp=mean(tempdata,na.rm=T))\n#These values are too warm in the earlier months and too cold in the later months\n#q2c\nanyDuplicated(temperature$tempdata)\n#there are no duplicates in the data set. \n#q2d\ny<-seq(as.Date(\"2010-1-1\"),as.Date(\"2010-6-30\"), by=\"2 days\")\nweather<-c(\"sunny\",\"cloudy\",\"partly cloudy\")\nb<-rnorm(c(y),mean=5,sd=3)\nobservations<-data.frame(as.Date(y),sample(weather,size=91, replace=T),b)\nobservations$b[b<0]<-0\n#q2e\nWeather<-merge(temperature, observations, by.x=\"as.Date.x.\",by.y=\"as.Date.y.\", all=F,incomparables=NULL)\n#q2f\nminmaxcond<-data.frame(t(c(min(Weather$tempdata),max(Weather$tempdata),\n                          min(Weather$b),max(Weather$b))))\nminmaxcond<-rename(minmaxcond,c(\"X1\"=\"Min Temp\",\"X2\"=\"Max Temp\",\"X3\"=\"Min Wind\",\"X4\"=\"Max Wind\"))\ntable(Weather$sample.weather..size...91..replace...T.)\n",
    "created" : 1413849961888.000,
    "dirty" : false,
    "encoding" : "UTF-8",
    "folds" : "",
    "hash" : "3054335050",
    "id" : "51221A43",
    "lastKnownWriteTime" : 1413932017,
    "path" : "~/R/IntroR/Heare_Assignment3.R",
    "project_path" : "Heare_Assignment3.R",
    "properties" : {
        "tempName" : "Untitled1"
    },
    "source_on_save" : false,
    "type" : "r_source"
}