library(plyr)
library(ggplot2)
library(scales)
fidaugfeb<-read.table('FidAugtoFeb.csv', row.names=1)
#read in data, first change column names and remove data name in excel to make it work
head(fidaugfeb)
##          V2    V3    V4
## 1 8/17/2013  9:51 21.38
## 2 8/17/2013 10:06 21.57
## 3 8/17/2013 10:21 21.57
## 4 8/17/2013 10:36 21.76
## 5 8/17/2013 10:51 22.05
## 6 8/17/2013 11:06 22.05
fidaugfeb<-rename(fidaugfeb, c("V2"="Date",'V3'='Time','V4'='Temp'))
#rename columns
fidaugfeb$Date<-as.Date(fidaugfeb$Date, "%m/%d/%Y")
#tell R that these are dates
tmptst<-ddply(fidaugfeb,.(Date),summarise, mean_temp=mean(Temp,na.rm=T))
#creates mean temperature per date using summary statistics and ddply
plot(mean_temp~Date,data=tmptst)

plot of chunk unnamed-chunk-1

fidfebmay<-read.table('FidalgoFebtoMay2014.csv', row.names=1)
fidmayjun<-read.table('FidalgoMaytoJun14.csv', row.names=1)
fidjunjul<-read.table('FidalgoJuntoJul14.csv', row.names=1)
fidjuloct<-read.table('FidalgoJultoOct2014.csv', row.names=1)
fidjunoct<-read.table('FidalgoJuntoOct2014.csv', row.names=1)
#entered in all other CSVs
fidfebmay<-rename(fidfebmay, c("V2"="Date",'V3'='Time','V4'='Temp'))
fidmayjun<-rename(fidmayjun, c("V2"="Date",'V3'='Time','V4'='Temp'))
fidjunjul<-rename(fidjunjul, c("V2"="Date",'V3'='Time','V4'='Temp'))
fidjunoct<-rename(fidjunoct, c("V2"="Date",'V3'='Time','V4'='Temp'))
fidjuloct<-rename(fidjuloct, c("V2"="Date",'V3'='Time','V4'='Temp'))
#rename columns
fidfebmay$Date<-as.Date(fidfebmay$Date, "%m/%d/%Y")
fidmayjun$Date<-as.Date(fidmayjun$Date, "%m/%d/%Y")
fidjunjul$Date<-as.Date(fidjunjul$Date, "%m/%d/%Y")
fidjunoct$Date<-as.Date(fidjunoct$Date, "%m/%d/%Y")
fidjuloct$Date<-as.Date(fidjuloct$Date, "%m/%d/%Y")
#Date column as dates
fidy1<-rbind(fidaugfeb,fidfebmay,fidmayjun,fidjunjul,fidjunoct,fidjuloct)
#concats all temp data

fidy1edit<-read.csv("fidY1.csv")
#reads in edited CSV to correct for outliers.
fidy1edit$Date<-as.Date(fidy1edit$Date, "%m/%d/%Y")
#Dates as DATES in r
fidy1editv2<-rbind(fidy1edit,fidjunoct,fidjuloct)
#adds data for June and July to October to preedited temp.
fidy1editv2$Date<-as.Date(fidy1editv2$Date)
#turns dates into dates in r

fidy1v3<-read.csv("fidy1v3.csv")
#reads in editted temp file
fidy1v3$Date<-as.Date(fidy1v3$Date,"%m/%d/%Y")
#turns dates into DATES in r
fidmeantemp<-ddply(fidy1v3,.(Date),summarise,mean_temp=mean(Temp,na.rm=T))
#creates mean temp file
fidmintemp<-ddply(fidy1v3,.(Date),summarise,min_temp=min(Temp,na.rm=T))
#creates min temp file
fidmaxtemp<-ddply(fidy1v3,.(Date),summarise,max_temp=max(Temp,na.rm=T))
#creates max temp file
fidmedtemp<-ddply(fidy1v3,.(Date),summarise,med_temp=median(Temp,na.rm=T))
#creates med temp file
ggplot(data=fidmedtemp, aes(Date, med_temp, group=1))+geom_line(color="purple",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

plot of chunk unnamed-chunk-1

#plots median temps
ggplot(data=fidmintemp, aes(Date, min_temp, group=1))+geom_line(color="purple",size=1.5)+geom_abline(intercept=12.5, slope=0,color="red", size=2)+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

plot of chunk unnamed-chunk-1

#plots min temps
ggplot()+geom_line(data=fidmeantemp, aes(Date,mean_temp, group=1), color="Purple",size=1)+geom_line(data=fidmintemp, aes(Date,min_temp,group=1),color="Blue",size=1)+geom_line(data=fidmaxtemp,aes(Date,max_temp,group=1),color="Red",size=1)+geom_abline(intercept=12.5, slope=0,color="Red", size=0.5)+labs(x="Date",y="Min|Max|Mean Temperatures(C)")+scale_x_date(breaks="1 month", minor_breaks="1 week",labels=date_format("%B %Y"))+theme(axis.text.x=element_text(angle=45, size=10, vjust=0.5))

plot of chunk unnamed-chunk-1

#plots all temps