Skip to content
Snippets Groups Projects
Commit b79e12d4 authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Added a logical argument to decide whether or not to convert from cfs to cms.

parent c5957453
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#' @param StartDate string starting date for data retrieval in the form YYYY-MM-DD. #' @param StartDate string starting date for data retrieval in the form YYYY-MM-DD.
#' @param EndDate string ending date for data retrieval in the form YYYY-MM-DD. #' @param EndDate string ending date for data retrieval in the form YYYY-MM-DD.
#' @param interactive logical Option for interactive mode. If true, there is user interaction for error handling and data checks. #' @param interactive logical Option for interactive mode. If true, there is user interaction for error handling and data checks.
#' @param convert logical Option to include a conversion from cfs to cms (35.314667). The default is TRUE,
#' which is appropriate for using NWIS data in the EGRET package. Set this to FALSE to not include the conversion.
#' @keywords data import USGS WRTDS #' @keywords data import USGS WRTDS
#' @export #' @export
#' @return Daily dataframe #' @return Daily dataframe
...@@ -16,10 +18,12 @@ ...@@ -16,10 +18,12 @@
#' @examples #' @examples
#' # These examples require an internet connection to run #' # These examples require an internet connection to run
#' Daily <- getDVData('01594440','00060', '1985-01-01', '1985-03-31', interactive=FALSE) #' Daily <- getDVData('01594440','00060', '1985-01-01', '1985-03-31', interactive=FALSE)
getDVData <- function (siteNumber,ParameterCd,StartDate,EndDate,interactive=TRUE){ getDVData <- function (siteNumber,ParameterCd,StartDate,EndDate,interactive=TRUE,convert=TRUE){
data <- retrieveNWISData(siteNumber,ParameterCd,StartDate,EndDate,interactive=interactive) data <- retrieveNWISData(siteNumber,ParameterCd,StartDate,EndDate,interactive=interactive)
# need to setup conversion factor because the NWIS data are in cfs but we store in cms # need to setup conversion factor because the NWIS data are in cfs but we store in cms
qConvert<-35.314667 names(data) <- c('agency', 'site', 'dateTime', 'value', 'code') # do a merge instead?
qConvert<- ifelse(convert,35.314667,1)
localDaily <- populateDaily(data,qConvert,interactive=interactive) localDaily <- populateDaily(data,qConvert,interactive=interactive)
return (localDaily) return (localDaily)
} }
\ No newline at end of file
...@@ -64,15 +64,15 @@ retrieveNWISData <- function (siteNumber,ParameterCd,StartDate,EndDate,StatCd="0 ...@@ -64,15 +64,15 @@ retrieveNWISData <- function (siteNumber,ParameterCd,StartDate,EndDate,StatCd="0
if(class(ret.val) == "try-error") if(class(ret.val) == "try-error")
ret.val <- x ret.val <- x
} }
else if(regexpr('n$', Typ) > 0) # Must be numeric...be careful of ice # else if(regexpr('n$', Typ) > 0) # Must be numeric...be careful of ice
ret.val <- as.numeric(x) # ret.val <- as.numeric(x)
else # Must be character else # Must be character
ret.val <- x ret.val <- x
return(ret.val)}) return(ret.val)})
retval <- as.data.frame(retval, stringsAsFactors=FALSE) retval <- as.data.frame(retval, stringsAsFactors=FALSE)
colNames <- names(retval) # colNames <- names(retval)
names(retval) <- c('agency', 'site', 'dateTime', 'value', 'code') # do a merge instead?
return (retval) return (retval)
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment