#Import climate CSV
#Create climateData Dataframe
climateData<-read.csv("climate.csv",header=TRUE,stringsAsFactors = TRUE)

#Display dataframe
View(climateData)

#Create cumulativeData data frame
cumulativeData<-climateData[,c(1:2,6,9)]
cumulativeData$cumRain<-ave(cumulativeData$Precipitation...Rainfall.mm,cumulativeData$Location,FUN = cumsum)
cumulativeData$cumSun<-ave(cumulativeData$Avg..Sun.hours..hours.,cumulativeData$Location,FUN = cumsum)
View(cumulativeData)

#Create display graph function
#city parameter is a string being either "Swansea" or "Wuhan"
#weather is an integer based on column number of required value
displayGraph<-function(city,weather)
{
if (weather == 3)
{plot(sort(as.integer(climateData$Month[climateData$Location==city])),climateData$Avg..Temperature..C[climateData$Location==city],
        type="l",xlab = "Month",ylab = "Avg Temp")}
if (weather == 4)
{plot(sort(as.integer(climateData$Month[climateData$Location==city])),climateData$Min..Temperature..C[climateData$Location==city],
        type="l",xlab = "Month",ylab = "Min Temp")}
if (weather == 5)
{plot(sort(as.integer(climateData$Month[climateData$Location==city])),climateData$Max..Temperature..C[climateData$Location==city],
        type="l",xlab = "Month",ylab = "Max Temp")}
if (weather == 6)
{plot(sort(as.integer(climateData$Month[climateData$Location==city])),climateData$Precipitation...Rainfall.mm[climateData$Location==city],
        type="l",xlab = "Month",ylab = "Rainfall")}
if (weather == 7)
{plot(sort(as.integer(climateData$Month[climateData$Location==city])),climateData$Humidity...[climateData$Location==city],
        type="l",xlab = "Month",ylab = "Humidity")}
if (weather == 8)
{plot(sort(as.integer(climateData$Month[climateData$Location==city])),climateData$Rainy.days..d.[climateData$Location==city],
        type="l",xlab = "Month",ylab = "Rainy Days")}
if (weather == 9)
{plot(sort(as.integer(climateData$Month[climateData$Location==city])),climateData$Avg..Sun.hours..hours.[climateData$Location==city],
        type="l",xlab = "Month",ylab = "Avg Sun Hours")}
}

#Use function to display Humidity in Wuhan
displayGraph("Wuhan",7)

#Use function to display rainfall in Swansea
displayGraph("Swansea",6)

compareCities<-function(monthStart,monthEnd,weather1,weather2)
{
  
  
}