diff --git a/R/getDVData.r b/R/getDVData.r index ff8ffd4a2c025f0bbfbdcfc8c54da461df527583..2bc1677c624a1886500972bbe9c359d951e54951 100644 --- a/R/getDVData.r +++ b/R/getDVData.r @@ -9,6 +9,8 @@ #' @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 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 #' @export #' @return Daily dataframe @@ -16,10 +18,12 @@ #' @examples #' # These examples require an internet connection to run #' 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) + # 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) return (localDaily) } \ No newline at end of file diff --git a/R/retrieveNWISData.r b/R/retrieveNWISData.r index ac99bf09c89fe55d5257783062d93d2368e61ba8..8e3ca9454a4016dcc0f0da75c9d581a9791a8a07 100644 --- a/R/retrieveNWISData.r +++ b/R/retrieveNWISData.r @@ -64,15 +64,15 @@ retrieveNWISData <- function (siteNumber,ParameterCd,StartDate,EndDate,StatCd="0 if(class(ret.val) == "try-error") ret.val <- x } - else if(regexpr('n$', Typ) > 0) # Must be numeric...be careful of ice - ret.val <- as.numeric(x) +# else if(regexpr('n$', Typ) > 0) # Must be numeric...be careful of ice +# ret.val <- as.numeric(x) else # Must be character ret.val <- x return(ret.val)}) 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) } \ No newline at end of file