From ae0e8f7da274d9e338707ed70ff2725e3c8b3f7b Mon Sep 17 00:00:00 2001 From: Laura DeCicco Date: Fri, 20 Jan 2017 13:41:38 -0600 Subject: [PATCH] Edits suggested by review --- R/importRDB1.r | 18 +++++++++--------- R/importWaterML1.r | 16 ++++++++-------- R/importWaterML2.r | 14 +++++++------- man/importRDB1.Rd | 11 ++++++----- man/importWaterML1.Rd | 11 ++++++----- man/importWaterML2.Rd | 11 ++++++----- 6 files changed, 42 insertions(+), 39 deletions(-) diff --git a/R/importRDB1.r b/R/importRDB1.r index be8d5f93..a7dbae63 100644 --- a/R/importRDB1.r +++ b/R/importRDB1.r @@ -7,10 +7,11 @@ #' #' @param obs_url character containing the url for the retrieval or a file path to the data file. #' @param asDateTime logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, Date -#' @param tz character to set timezone attribute of datetime. Default is an empty quote, which converts the -#' datetimes to UTC (properly accounting for daylight savings times based on the data's provided tz_cd column). -#' Possible values to provide include "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", -#' "America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla" +#' @param tz character to set timezone attribute of datetime. Default converts the datetimes to UTC +#' (properly accounting for daylight savings times based on the data's provided tz_cd column). +#' Recommended US values include "UTC","America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", +#' "America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla". +#' For a complete list, see \url{https://en.wikipedia.org/wiki/List_of_tz_database_time_zones} #' @param convertType logical, defaults to \code{TRUE}. If \code{TRUE}, the function will convert the data to dates, datetimes, #' numerics based on a standard algorithm. If false, everything is returned as a character #' @return A data frame with the following columns: @@ -83,14 +84,13 @@ #' fullPath <- file.path(filePath, fileName) #' importUserRDB <- importRDB1(fullPath) #' -importRDB1 <- function(obs_url, asDateTime=TRUE, convertType = TRUE, tz=""){ +importRDB1 <- function(obs_url, asDateTime=TRUE, convertType = TRUE, tz="UTC"){ - if(tz != ""){ - tz <- match.arg(tz, OlsonNames()) - } else { - tz <- "UTC" + if(tz == ""){ + tz <- "UTC" } + tz <- match.arg(tz, OlsonNames()) if(file.exists(obs_url)){ doc <- obs_url diff --git a/R/importWaterML1.r b/R/importWaterML1.r index e1e4ebb9..6d3be092 100644 --- a/R/importWaterML1.r +++ b/R/importWaterML1.r @@ -5,10 +5,11 @@ #' #' @param obs_url character or raw, containing the url for the retrieval or a file path to the data file, or raw XML. #' @param asDateTime logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, Date -#' @param tz character to set timezone attribute of . Default is an empty quote, which converts the -#' s to UTC (properly accounting for daylight savings times based on the data's provided tz_cd column). -#' Possible values to provide include "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", -#' "America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla" +#' @param tz character to set timezone attribute of datetime. Default converts the datetimes to UTC +#' (properly accounting for daylight savings times based on the data's provided tz_cd column). +#' Recommended US values include "UTC","America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", +#' "America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla". +#' For a complete list, see \url{https://en.wikipedia.org/wiki/List_of_tz_database_time_zones} #' @return A data frame with the following columns: #' \tabular{lll}{ #' Name \tab Type \tab Description \cr @@ -108,7 +109,7 @@ #' importFile <- importWaterML1(fullPath,TRUE) #' -importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){ +importWaterML1 <- function(obs_url,asDateTime=FALSE, tz="UTC"){ #note: obs_url is a dated name, does not have to be a url/path raw <- FALSE if(class(obs_url) == "character" && file.exists(obs_url)){ @@ -120,11 +121,10 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){ returnedDoc <- xml_root(getWebServiceData(obs_url, encoding='gzip')) } - if(tz != ""){ #check tz is valid if supplied - tz <- match.arg(tz, OlsonNames()) - } else { + if(tz == ""){ #check tz is valid if supplied tz <- "UTC" } + tz <- match.arg(tz, OlsonNames()) timeSeries <- xml_find_all(returnedDoc, ".//ns1:timeSeries") #each parameter/site combo diff --git a/R/importWaterML2.r b/R/importWaterML2.r index 50f2f2cc..de982db5 100644 --- a/R/importWaterML2.r +++ b/R/importWaterML2.r @@ -5,10 +5,11 @@ #' #' @param obs_url character or raw, containing the url for the retrieval or a path to the data file, or raw XML. #' @param asDateTime logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, character -#' @param tz character to set timezone attribute of datetime. Default is an empty quote, which converts the -#' datetimes to UTC (properly accounting for daylight savings times based on the data's provided tz_cd column). -#' Possible values to provide include "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", -#' "America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla" +#' @param tz character to set timezone attribute of datetime. Default converts the datetimes to UTC +#' (properly accounting for daylight savings times based on the data's provided tz_cd column). +#' Recommended US values include "UTC","America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", +#' "America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla". +#' For a complete list, see \url{https://en.wikipedia.org/wiki/List_of_tz_database_time_zones} #' @return mergedDF a data frame time, value, description, qualifier, and identifier #' @export #' @importFrom xml2 read_xml @@ -39,13 +40,12 @@ #' fullPath <- file.path(filePath, fileName) #' UserData <- importWaterML2(fullPath) #' -importWaterML2 <- function(obs_url, asDateTime=FALSE, tz=""){ +importWaterML2 <- function(obs_url, asDateTime=FALSE, tz="UTC"){ if(tz != ""){ - tz <- match.arg(tz, OlsonNames()) - } else { tz = "UTC" } + tz <- match.arg(tz, OlsonNames()) raw <- FALSE if(class(obs_url) == "character" && file.exists(obs_url)){ diff --git a/man/importRDB1.Rd b/man/importRDB1.Rd index f6c3324b..19a0895d 100644 --- a/man/importRDB1.Rd +++ b/man/importRDB1.Rd @@ -4,7 +4,7 @@ \alias{importRDB1} \title{Function to return data from the NWIS RDB 1.0 format} \usage{ -importRDB1(obs_url, asDateTime = TRUE, convertType = TRUE, tz = "") +importRDB1(obs_url, asDateTime = TRUE, convertType = TRUE, tz = "UTC") } \arguments{ \item{obs_url}{character containing the url for the retrieval or a file path to the data file.} @@ -14,10 +14,11 @@ importRDB1(obs_url, asDateTime = TRUE, convertType = TRUE, tz = "") \item{convertType}{logical, defaults to \code{TRUE}. If \code{TRUE}, the function will convert the data to dates, datetimes, numerics based on a standard algorithm. If false, everything is returned as a character} -\item{tz}{character to set timezone attribute of datetime. Default is an empty quote, which converts the -datetimes to UTC (properly accounting for daylight savings times based on the data's provided tz_cd column). -Possible values to provide include "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", -"America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla"} +\item{tz}{character to set timezone attribute of datetime. Default converts the datetimes to UTC +(properly accounting for daylight savings times based on the data's provided tz_cd column). +Recommended US values include "UTC","America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", +"America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla". +For a complete list, see \url{https://en.wikipedia.org/wiki/List_of_tz_database_time_zones}} } \value{ A data frame with the following columns: diff --git a/man/importWaterML1.Rd b/man/importWaterML1.Rd index 65d03cb3..f50663e0 100644 --- a/man/importWaterML1.Rd +++ b/man/importWaterML1.Rd @@ -4,17 +4,18 @@ \alias{importWaterML1} \title{Function to return data from the NWISWeb WaterML1.1 service} \usage{ -importWaterML1(obs_url, asDateTime = FALSE, tz = "") +importWaterML1(obs_url, asDateTime = FALSE, tz = "UTC") } \arguments{ \item{obs_url}{character or raw, containing the url for the retrieval or a file path to the data file, or raw XML.} \item{asDateTime}{logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, Date} -\item{tz}{character to set timezone attribute of . Default is an empty quote, which converts the -s to UTC (properly accounting for daylight savings times based on the data's provided tz_cd column). -Possible values to provide include "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", -"America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla"} +\item{tz}{character to set timezone attribute of datetime. Default converts the datetimes to UTC +(properly accounting for daylight savings times based on the data's provided tz_cd column). +Recommended US values include "UTC","America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", +"America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla". +For a complete list, see \url{https://en.wikipedia.org/wiki/List_of_tz_database_time_zones}} } \value{ A data frame with the following columns: diff --git a/man/importWaterML2.Rd b/man/importWaterML2.Rd index 7a77bf84..383a3933 100644 --- a/man/importWaterML2.Rd +++ b/man/importWaterML2.Rd @@ -4,17 +4,18 @@ \alias{importWaterML2} \title{Function to return data from the WaterML2 data} \usage{ -importWaterML2(obs_url, asDateTime = FALSE, tz = "") +importWaterML2(obs_url, asDateTime = FALSE, tz = "UTC") } \arguments{ \item{obs_url}{character or raw, containing the url for the retrieval or a path to the data file, or raw XML.} \item{asDateTime}{logical, if \code{TRUE} returns date and time as POSIXct, if \code{FALSE}, character} -\item{tz}{character to set timezone attribute of datetime. Default is an empty quote, which converts the -datetimes to UTC (properly accounting for daylight savings times based on the data's provided tz_cd column). -Possible values to provide include "America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", -"America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla"} +\item{tz}{character to set timezone attribute of datetime. Default converts the datetimes to UTC +(properly accounting for daylight savings times based on the data's provided tz_cd column). +Recommended US values include "UTC","America/New_York","America/Chicago", "America/Denver","America/Los_Angeles", +"America/Anchorage","America/Honolulu","America/Jamaica","America/Managua","America/Phoenix", and "America/Metlakatla". +For a complete list, see \url{https://en.wikipedia.org/wiki/List_of_tz_database_time_zones}} } \value{ mergedDF a data frame time, value, description, qualifier, and identifier