diff --git a/DESCRIPTION b/DESCRIPTION index 711903d..de89fe2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: winfapReader Type: Package Title: Interact with Peak Flow Data in the United Kingdom -Version: 0.1-5.1 +Version: 0.1-5.2 Authors@R: c(person("Ilaria", "Prosdocimi", email = "prosdocimi.ilaria@gmail.com", role = c("aut", "cre"), @@ -27,7 +27,7 @@ Suggests: rmarkdown, zoo LazyData: true -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 VignetteBuilder: knitr Encoding: UTF-8 Language: en-GB diff --git a/NAMESPACE b/NAMESPACE index 3ef50d5..f2c9bb2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,4 +15,5 @@ importFrom(lubridate,leap_year) importFrom(lubridate,month) importFrom(lubridate,year) importFrom(lubridate,ymd) +importFrom(lubridate,ymd_hms) importFrom(utils,read.csv) diff --git a/NEWS.md b/NEWS.md index 804f443..5f4d5a3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +# winfapReader 0.1-5.2 +- changes in get_amax and get_pot (and in the internal read functions): this was needed to adjust to the changes in what the API outputs now + # winfapReader 0.1-5.1 - changes in known_Oct1 to include new events which occurred on Oct 1st which have been identified in version 12 of the winfap files - changes in test functions: realized I needed them after the API broke for some days diff --git a/R/dateManupulations.R b/R/dateManupulations.R index 7ff5221..495cf69 100644 --- a/R/dateManupulations.R +++ b/R/dateManupulations.R @@ -14,9 +14,11 @@ #' @importFrom lubridate leap_year #' @importFrom lubridate dmy #' @importFrom lubridate ymd +#' @importFrom lubridate ymd_hms #' @importFrom lubridate date #' @importFrom lubridate int_overlaps #' @importFrom lubridate interval +#' water_year <- function(date, start_month = 10){ # Given a date in ymd lubridate form, returns the WY that date is in. # The XXXX Water year starts 01st start_month XXXX and ends on the last day of the month before the start_month (XXXX+1) diff --git a/R/readerFuncs.R b/R/readerFuncs.R index 4e99c6f..214507a 100644 --- a/R/readerFuncs.R +++ b/R/readerFuncs.R @@ -105,7 +105,8 @@ read_pot_int <- function(filetext, getAmax){ names(WY_table) <- c("WaterYear","potPercComplete","potThreshold") tablePOT <- POTtable[seq(match('[POT Values]',POTtable[,1])+1,nrow(POTtable)-1),] names(tablePOT) <- c("Date","Flow","Stage") - tablePOT$Date <- dmy(tablePOT$Date) + if(grepl("-", tablePOT$Date[1])) tablePOT$Date <- ymd_hms(tablePOT$Date) + else tablePOT$Date <- dmy(tablePOT$Date) tablePOT$Flow <- as.numeric(tablePOT$Flow) tablePOT$Stage <- as.numeric(tablePOT$Stage) tablePOT$Station <- as.numeric(statno) @@ -197,7 +198,9 @@ read_amax_int <- function(filetext){ aa <- rr[(which(rr == "[AM Values]")+1):(length(rr)-1)] out <- cbind(station, utils::read.csv(textConnection(aa),header=FALSE, stringsAsFactors = FALSE)) names(out) <- c("Station","Date","Flow","Stage") - out$Date <- lubridate::dmy(out$Date) + if(grepl("-", out$Date[1])) out$Date <- ymd_hms(out$Date) + else out$Date <- dmy(out$Date) + # out$Date <- lubridate::dmy(out$Date) out$WaterYear <- water_year(out$Date) #### Check if any amax should be rejected rejStart <- grep("[AM Rejected]",rr,fixed = TRUE) diff --git a/docs/404.html b/docs/404.html index 96534db..e73f923 100644 --- a/docs/404.html +++ b/docs/404.html @@ -6,7 +6,7 @@