diff --git a/DESCRIPTION b/DESCRIPTION index d2cb638..59686cd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Type: Package Package: rsoi Title: Import Various Northern and Southern Hemisphere Climate Indices -Version: 0.5.2 +Version: 0.5.3 Authors@R: c(person(given = "Sam", family = "Albers", @@ -31,4 +31,4 @@ Suggests: tibble Encoding: UTF-8 LazyData: true -RoxygenNote: 7.0.2 +RoxygenNote: 7.1.0 diff --git a/NEWS.md b/NEWS.md index 634bd3c..390d092 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,9 @@ # rsoi NEWS + +## rsoi v0.5.3 +* Remove Extended PDO because data is no longer available. +* Fail more gracefully with data source issues + ## rsoi v0.5.2 * Adding PDO after rpdo maintainers requested we start importing. Thanks @eliocamp (#33) diff --git a/R/download-pdo.R b/R/download-pdo.R index f50e692..68b3183 100644 --- a/R/download-pdo.R +++ b/R/download-pdo.R @@ -23,7 +23,6 @@ #' \item Month: Month of record #' \item Year: Year of record #' \item PDO: Pacific Decadal Oscillation index -#' \item PDO_e: Extended PDO (NCEI PDO index) #' } #' @examples @@ -33,7 +32,6 @@ #' #' @references #' Original PDO: \url{https://oceanview.pfeg.noaa.gov/erddap/info/cciea_OC_PDO/index.html} -#' Extended PDO: \url{https://www.ncdc.noaa.gov/teleconnections/pdo/} download_pdo <- function(use_cache = FALSE, file = NULL) { with_cache(use_cache = use_cache, file = file, memoised = download_pdo_memoised, @@ -58,30 +56,30 @@ download_pdo_unmemoised <- function() { pdo$Date = as.Date(pdo$Date) # pdo extended reconstruction - pdo_link = paste0("https://www.ncdc.noaa.gov/teleconnections/pdo/data.csv") - - res = check_response(pdo_link) - - pdo_e = read.table(res, - col.names = c("Date", "PDO_e"), - skip = 2, - sep = ",", - stringsAsFactors = FALSE) - pdo_e$Year = as.numeric(substr(pdo_e$Date, 1, 4)) - pdo_e$Month = substr(pdo_e$Date, 5, 7) - pdo_e$Date = as.Date(paste0(pdo_e$Year, "-", pdo_e$Month, "-01")) - - pdo <- merge(pdo[, c("Date", "PDO")], - pdo_e[, c("Date", "PDO_e")], - by = "Date", - all = TRUE) + # pdo_link = paste0("https://www.ncdc.noaa.gov/teleconnections/pdo/data.csv") + # + # res = check_response(pdo_link) + # + # pdo_e = read.table(res, + # col.names = c("Date", "PDO_e"), + # skip = 2, + # sep = ",", + # stringsAsFactors = FALSE) + # pdo_e$Year = as.numeric(substr(pdo_e$Date, 1, 4)) + # pdo_e$Month = substr(pdo_e$Date, 5, 7) + # pdo_e$Date = as.Date(paste0(pdo_e$Year, "-", pdo_e$Month, "-01")) + # + # pdo <- merge(pdo[, c("Date", "PDO")], + # pdo_e[, c("Date", "PDO_e")], + # by = "Date", + # all = TRUE) pdo$Year = as.numeric(substr(pdo$Date, 1, 4)) pdo$Month = abbr_month(pdo$Date) class(pdo) <- c("tbl_df", "tbl", "data.frame") - pdo[, c("Year", "Month", "Date", "PDO", "PDO_e")] + pdo[, c("Year", "Month", "Date", "PDO")] } # Memoised function diff --git a/R/utils.R b/R/utils.R index 2be4bf4..7ac759d 100644 --- a/R/utils.R +++ b/R/utils.R @@ -17,7 +17,7 @@ check_response <- function(link){ response <- curl::curl_fetch_memory(link) if(!response$status_code == 200){ - stop(paste0("Non successful http request. Target server returning a ", response$status_code, " error code"), + warning(paste0("Non successful http request. Target server returning a ", response$status_code, " error code"), call. = FALSE) } diff --git a/cran-comments.md b/cran-comments.md index 791b812..139f2d4 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,21 +1,22 @@ # rsoi NEWS -## rsoi v0.5.2 -* Adding PDO after rpdo maintainers requested we start importing. Thanks @eliocamp (#33) +## rsoi v0.5.3 +* Removed extended PDO data source +* Fail more gracefully with data source issues ## Test environments -* local Windows 10, R 3.6.3 +* local Windows 10, R 4.0.2 * ubuntu, os x, R 3.6.3 (travis-ci) -* ubuntu 16.04 (on github actions), R 3.6, R 3.5, R 3.4, R 3.3 -* Windows Server 2019 (on github actions), R 3.6.3 -* macOS Catalina 10.15 (on github actions), R 3.6.3 +* ubuntu 16.04 (on github actions), 4.0.2, R 3.5, R 3.4, R 3.3 +* Windows Server 2019 (on github actions), R 4.0.2 +* macOS Catalina 10.15 (on github actions), R 4.0.2 * win-builder (devel and release) -* Windows, R 3.6.3 (on appveyor) +* Windows, R 4.0.2 (on appveyor) ## R CMD check results -There were no ERRORs or WARNINGs. +There were no ERRORs or WARNINGs. This fixes the error currently happening on CRAN right now. ## Downstream dependencies diff --git a/man/download_pdo.Rd b/man/download_pdo.Rd index 083da42..53920ad 100644 --- a/man/download_pdo.Rd +++ b/man/download_pdo.Rd @@ -19,7 +19,6 @@ if `file` is `NULL` or on disk if `file` is not `NULL`.} \item Month: Month of record \item Year: Year of record \item PDO: Pacific Decadal Oscillation index -\item PDO_e: Extended PDO (NCEI PDO index) } } \description{ @@ -41,5 +40,4 @@ pdo <- download_pdo() } \references{ Original PDO: \url{https://oceanview.pfeg.noaa.gov/erddap/info/cciea_OC_PDO/index.html} -Extended PDO: \url{https://www.ncdc.noaa.gov/teleconnections/pdo/} } diff --git a/man/rsoi-package.Rd b/man/rsoi-package.Rd index 080229b..1a7f6bf 100644 --- a/man/rsoi-package.Rd +++ b/man/rsoi-package.Rd @@ -14,7 +14,7 @@ or \href{https://github.com/boshek/rsoi/blob/master/README.md}{GitHub} Useful links: \itemize{ \item \url{https://github.com/boshek/rsoi} - \item \url{https://boshek.github.io/rsoi/} + \item \url{https://samalbers.science/rsoi} } }