Skip to content

Commit

Permalink
Edits suggested by review
Browse files Browse the repository at this point in the history
  • Loading branch information
ldecicco-USGS committed Jan 20, 2017
1 parent 465311c commit ae0e8f7
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 39 deletions.
18 changes: 9 additions & 9 deletions R/importRDB1.r
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions R/importWaterML1.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)){
Expand All @@ -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

Expand Down
14 changes: 7 additions & 7 deletions R/importWaterML2.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)){
Expand Down
11 changes: 6 additions & 5 deletions man/importRDB1.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions man/importWaterML1.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions man/importWaterML2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ae0e8f7

Please sign in to comment.