diff --git a/Modified Sequent Peak Algorithm (mSPA)/SPA.R b/Modified Sequent Peak Algorithm (mSPA)/SPA.R index 2b820bb938a7bffcd037320e93addbbc694b213c..4b4c7114976593c11c43558acd6f7bdd3a49882b 100644 --- a/Modified Sequent Peak Algorithm (mSPA)/SPA.R +++ b/Modified Sequent Peak Algorithm (mSPA)/SPA.R @@ -7,24 +7,23 @@ data <- readr::read_delim( delim = "\t", col_names = c("inflow", "release", "precip", "evapo", "downstreamFlow") ) -time <- - data.frame(seq(as.Date("1961/1/1"), as.Date("2007/12/31"), "month")) -month <- - data.frame(format( +time <- seq(as.Date("1961/1/1"), as.Date("2007/12/31"), "month") +stora <- data.frame( + Month = format( as.Date( - time$seq.as.Date..1961.1.1....as.Date..2007.12.31.....month.., + time, format = "%Y-%m-%d" ), "%m" - )) -year <- - data.frame(format( + ), + Year= format( as.Date( - time$seq.as.Date..1961.1.1....as.Date..2007.12.31.....month.., + time, format = "%Y-%m-%d" ), "%Y" - )) + ) +) n <- NROW(na.omit(data)) Inflow <- data$inflow dem <- data$release @@ -80,10 +79,8 @@ for (i in 2:n + 1) { Zt[i - 1] <- S - Kt1[i - 1] } -stora <- - data.frame(year, month, Zt) # [ Storage = reservoir capacity - Deficit ] -names(stora)[1] <- "Year" -names(stora)[2] <- "Month" +stora$Zt <- Zt # [ Storage = reservoir capacity - Deficit ] + ST <- reshape( data = stora, idvar = "Year",