diff --git a/R/reformat_GSOD.R b/R/reformat_GSOD.R index 6c8ea997..bf5d4877 100644 --- a/R/reformat_GSOD.R +++ b/R/reformat_GSOD.R @@ -16,12 +16,14 @@ #' up a parallel backend of your choice, \emph{e.g.}, #' \code{future::plan("multisession")}. See Examples for more. #' -#' @param dsn User supplied file path to location of data files on local disk -#' for tidying. -#' @param file_list User supplied list of files of data on local disk for -#' tidying. +#' @param dsn User supplied full file path to location of data files on local +#' disk for tidying. +#' @param file_list User supplied list of file paths to individual files of data +#' on local disk for tidying. Ignored if \code{dsn} is set. Use if there are +#' other files in the \code{dsn} that you do not wish to reformat. #' #' @details +#' #' If multiple stations are given, data are summarised for each year by station, #' which include vapour pressure and relative humidity elements calculated from #' existing data in \acronym{GSOD}. Else, a single station is tidied and a data @@ -93,6 +95,13 @@ reformat_GSOD <- function(dsn = NULL, file_list = NULL) { load(system.file("extdata", "isd_history.rda", package = "GSODR")) # nocov setkeyv(isd_history, "STNID") + # If both dsn and file_path are set, emit message that only dsn is used + if (!is.null(dsn) & !is.null(file_list)) { + message("\nYou have specified both `file_list` and `dsn`.\n", + "Proceeding with using only the value from `dsn`.\n", + "See `?reformat_GSOD` if this behaviour was not expected.\n") + } + # If dsn !NULL, create a list of files to reformat if (!is.null(dsn)) { file_list <- list.files(path = dsn, diff --git a/man/reformat_GSOD.Rd b/man/reformat_GSOD.Rd index 02c63236..0bb0b8a6 100644 --- a/man/reformat_GSOD.Rd +++ b/man/reformat_GSOD.Rd @@ -7,11 +7,12 @@ reformat_GSOD(dsn = NULL, file_list = NULL) } \arguments{ -\item{dsn}{User supplied file path to location of data files on local disk -for tidying.} +\item{dsn}{User supplied full file path to location of data files on local +disk for tidying.} -\item{file_list}{User supplied list of files of data on local disk for -tidying.} +\item{file_list}{User supplied list of file paths to individual files of data +on local disk for tidying. Ignored if \code{dsn} is set. Use if there are +other files in the \code{dsn} that you do not wish to reformat.} } \value{ A data frame as a \code{\link[data.table]{data.table}} object of @@ -35,6 +36,7 @@ up a parallel backend of your choice, \emph{e.g.}, \code{future::plan("multisession")}. See Examples for more. + If multiple stations are given, data are summarised for each year by station, which include vapour pressure and relative humidity elements calculated from existing data in \acronym{GSOD}. Else, a single station is tidied and a data diff --git a/tests/testthat/test-reformat_GSOD.R b/tests/testthat/test-reformat_GSOD.R index bc0b4712..67af90d9 100644 --- a/tests/testthat/test-reformat_GSOD.R +++ b/tests/testthat/test-reformat_GSOD.R @@ -11,7 +11,8 @@ test_that("reformat_GSOD file_list parameter reformats data properly", { # set up options for curl - url_base <- "https://www.ncei.noaa.gov/data/global-summary-of-the-day/access/1960/" + url_base <- + "https://www.ncei.noaa.gov/data/global-summary-of-the-day/access/1960/" test_files <- c("06600099999.csv", "06620099999.csv") destinations <- file.path(tempdir(), test_files) @@ -45,6 +46,11 @@ test_that("reformat_GSOD file_list parameter reformats data properly", { expect_length(x, 44) expect_is(x, "data.frame") + # Check that a message is emitted when both dsn and file_list are set -------- + expect_message(reformat_GSOD(dsn = tempdir(), + file_list = file_list), + regexp = "\nYou have specified both `file_list` and `dsn`. *") + unlink(destinations) })