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

Taking out error handling from help files.

parent c0ff6e7b
No related branches found
No related tags found
No related merge requests found
Showing
with 51 additions and 232 deletions
export(checkStartEndDate)
export(compressData) export(compressData)
export(dataOverview) export(dataOverview)
export(dateFormatCheck)
export(formatCheckDate)
export(formatCheckParameterCd)
export(formatCheckSiteNumber)
export(getDVData) export(getDVData)
export(getDailyDataFromFile) export(getDailyDataFromFile)
export(getDataFromFile) export(getDataFromFile)
...@@ -30,5 +25,11 @@ export(populateSiteINFO) ...@@ -30,5 +25,11 @@ export(populateSiteINFO)
export(removeDuplicates) export(removeDuplicates)
export(retrieveNWISData) export(retrieveNWISData)
export(retrieveUnitNWISData) export(retrieveUnitNWISData)
export(formatCheckDate)
export(checkStartEndDate)
export(dateFormatCheck)
export(formatCheckParameterCd)
export(formatCheckSiteNumber)
exportClasses(fluxUnit)
exportClasses(fluxUnit) exportClasses(fluxUnit)
import(zoo) import(zoo)
#' Check Start End Dates
#'
#' Checks that the user-supplied starting date is before the ending date. If not, either the user can re-enter, or the dates will be set to maximum.
#'
#' @param StartDate string date
#' @param EndDate string date
#' @param interactive logical Option for interactive mode. If true, there is user interaction for error handling and data checks.
#' @keywords data import from web service
#' @return list StartDate,EndDate
#' @export
#' @examples
#' checkStartEndDate('1985-01-01', '1985-12-31')
checkStartEndDate <- function(StartDate, EndDate,interactive=TRUE){ checkStartEndDate <- function(StartDate, EndDate,interactive=TRUE){
start <- as.Date("1850-01-01") start <- as.Date("1850-01-01")
end <- as.Date(Sys.Date()) end <- as.Date(Sys.Date())
......
#' Date Formatting Check
#'
#' Checks that the user-supplied date is in the format YYYY-MM-DD and month is less than 13, and dates are less than 32.
#'
#' @param date string date to check
#' @keywords data import from web service
#' @return Date logical
#' @export
#' @examples
#' dateFormatCheck('1985-01-01')
#' dateFormatCheck('01/01/1985')
dateFormatCheck <- function(date){ # checks for the format YYYY-MM-DD dateFormatCheck <- function(date){ # checks for the format YYYY-MM-DD
parts <- strsplit(date,"-",fixed=TRUE) parts <- strsplit(date,"-",fixed=TRUE)
condition <- FALSE condition <- FALSE
......
#' Date Formatting Correction
#'
#' Checks that the user-supplied date is in the format YYYY-MM-DD. If not, asks the user to re-enter.
#'
#' @param Date string date to check
#' @param dateString string should be either 'StartDate' or 'EndDate'
#' @param interactive logical Option for interactive mode. If true, there is user interaction for error handling and data checks.
#' @keywords data import from web service
#' @return Date string
#' @export
#' @examples
#' formatCheckDate('1985-01-01', 'StartDate')
formatCheckDate <- function(Date, dateString,interactive=TRUE){ formatCheckDate <- function(Date, dateString,interactive=TRUE){
if(nzchar(Date)){ if(nzchar(Date)){
if (!dateFormatCheck(Date)){ if (!dateFormatCheck(Date)){
......
#' Parameter Code Check
#'
#' Checks that the user-supplied parameter code is 5 digits. If not, asks the user to re-enter.
#'
#' @param ParameterCd string USGS parameter code
#' @param interactive logical Option for interactive mode. If true, there is user interaction for error handling and data checks.
#' @keywords data import from web service
#' @return ParameterCd string
#' @export
#' @examples
#' formatCheckParameterCd('00060')
formatCheckParameterCd <- function(ParameterCd, interactive=TRUE){ #checks for a 5 digit number formatCheckParameterCd <- function(ParameterCd, interactive=TRUE){ #checks for a 5 digit number
if (nchar(ParameterCd) != 5){ if (nchar(ParameterCd) != 5){
if (interactive){ if (interactive){
......
#' Site number check
#'
#' Checks that the user-supplied site number is 8 digits, typical for many USGS station site id's.If not, asks the user to re-enter.
#' The final siteNumber can be more or less than 8 digits, since there are conditions where that is the case.
#'
#' @param siteNumber string USGS site number
#' @param interactive logical Option for interactive mode. If true, there is user interaction for error handling and data checks.
#' @keywords error checking for data import from web service
#' @return siteNumber string
#' @export
#' @examples
#' formatCheckSiteNumber('01594440')
#' formatCheckSiteNumber('015944400',interactive=FALSE)
formatCheckSiteNumber <- function(siteNumber, interactive=TRUE){ #checks for a 8 digit number formatCheckSiteNumber <- function(siteNumber, interactive=TRUE){ #checks for a 8 digit number
if (nchar(siteNumber) != 8){ if (nchar(siteNumber) != 8){
if (interactive){ if (interactive){
......
#' Data Import for USGS NWIS Data #' Raw Data Import for USGS NWIS Data
#' #'
#' Imports data from NWIS web service. This function gets the data from here: \url{http://waterservices.usgs.gov/} #' Imports data from NWIS web service. This function gets the data from here: \url{http://waterservices.usgs.gov/}
#' A list of parameter codes can be found here: \url{http://nwis.waterdata.usgs.gov/nwis/pmcodes/} #' A list of parameter codes can be found here: \url{http://nwis.waterdata.usgs.gov/nwis/pmcodes/}
......
#' Data Import for Instantaneous USGS NWIS Data #' Raw Data Import for Instantaneous USGS NWIS Data
#' #'
#' Imports data from NWIS web service. This function gets the data from here: \url{http://waterservices.usgs.gov/} #' Imports data from NWIS web service. This function gets the data from here: \url{http://waterservices.usgs.gov/}
#' A list of parameter codes can be found here: \url{http://nwis.waterdata.usgs.gov/nwis/pmcodes/} #' A list of parameter codes can be found here: \url{http://nwis.waterdata.usgs.gov/nwis/pmcodes/}
...@@ -20,11 +20,15 @@ ...@@ -20,11 +20,15 @@
#' # These examples require an internet connection to run #' # These examples require an internet connection to run
#' rawData <- retrieveUnitNWISData(siteNumber,ParameterCd,StartDate,EndDate,interactive=FALSE) #' rawData <- retrieveUnitNWISData(siteNumber,ParameterCd,StartDate,EndDate,interactive=FALSE)
retrieveUnitNWISData <- function (siteNumber,ParameterCd,StartDate,EndDate,interactive=TRUE){ retrieveUnitNWISData <- function (siteNumber,ParameterCd,StartDate,EndDate,interactive=TRUE){
# Checking for 8 digit site ID:
siteNumber <- formatCheckSiteNumber(siteNumber, interactive=interactive) siteNumber <- formatCheckSiteNumber(siteNumber, interactive=interactive)
# Check for 5 digit parameter code:
ParameterCd <- formatCheckParameterCd(ParameterCd, interactive=interactive) ParameterCd <- formatCheckParameterCd(ParameterCd, interactive=interactive)
# Check date format:
StartDate <- formatCheckDate(StartDate, "StartDate", interactive=interactive) StartDate <- formatCheckDate(StartDate, "StartDate", interactive=interactive)
EndDate <- formatCheckDate(EndDate, "EndDate", interactive=interactive) EndDate <- formatCheckDate(EndDate, "EndDate", interactive=interactive)
#Check that
dateReturn <- checkStartEndDate(StartDate, EndDate, interactive=interactive) dateReturn <- checkStartEndDate(StartDate, EndDate, interactive=interactive)
StartDate <- dateReturn[1] StartDate <- dateReturn[1]
EndDate <- dateReturn[2] EndDate <- dateReturn[2]
......
...@@ -47,13 +47,27 @@ NULL ...@@ -47,13 +47,27 @@ NULL
#' Flux units included in dataRetrieval #' Flux units included in dataRetrieval
#' #'
#' Flux units #' Flux units included:
#' \tabular{lllll}{
#' Number \tab ObjectName \tab shortName \tab unitFactor \tab unitName \cr
#' 1 \tab POUNDS_DAY \tab lbs/day \tab 2.204623 \tab pounds/day\cr
#' 2 \tab TONS_DAY \tab tons/day \tab 0.001102 \tab tons/day \cr
#' 3 \tab KG_DAY \tab kg/day \tab 1 \tab kg/day \cr
#' 4 \tab THOUSAND_KG_DAY\tab 10^3 kg/day \tab 0.001 \tab "thousands of kg/day\cr
#' 5 \tab TONS_YEAR\tab tons/yr \tab 0.402619 \tab tons/year\cr
#' 6 \tab THOUSAND_TONS_YEAR\tab 10^3 tons/yr \tab 0.000402619 \tab thousands of tons/year \cr
#' 7 \tab MILLION_TONS_YEAR\tab 10^6 tons/yr \tab 4.02619e-07 \tab millions of tons/year\cr
#' 8 \tab THOUSAND_KG_YEAR\tab 10^3 kg/yr \tab 0.36525 \tab thousands of kg/year\cr
#' 9 \tab MILLION_KG_YEAR\tab 10^6 kg/yr \tab 0.00036525 \tab millions of kg/year\cr
#' 10 \tab BILLION_KG_YEAR\tab 10^9 kg/yr \tab 3.6525e-07 \tab billions of kg/year \cr
#' }
#'
#' #'
#' @name FLUX_UNIT #' @name FLUX_UNIT
#' @docType data #' @docType data
NULL NULL
#' Sample Dataframe included in dataRetrieval #' Example Sample Dataframe included in dataRetrieval
#' #'
#' Initial Sample data frame from the Choptank River #' Initial Sample data frame from the Choptank River
#' #'
...@@ -63,7 +77,7 @@ NULL ...@@ -63,7 +77,7 @@ NULL
#' @keywords water flow data #' @keywords water flow data
NULL NULL
#' Daily Dataframe included in dataRetrieval #' Example Daily Dataframe included in dataRetrieval
#' #'
#' Initial Daily data frame from the Choptank River #' Initial Daily data frame from the Choptank River
#' #'
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
%------------------------------------------------------------ %------------------------------------------------------------
\section{Introduction to dataRetrieval} \section{Introduction to dataRetrieval}
%------------------------------------------------------------ %------------------------------------------------------------
The dataRetrieval package was created to simplify the process of getting hydrologic data in the R enviornment. It has been specifically designed to work seamlessly with the EGRET package: Exploration and Graphics for RivEr Trends (EGRET) . The dataRetrieval package was created to simplify the process of getting hydrologic data in the R enviornment. It has been specifically designed to work seamlessly with the EGRET package: Exploration and Graphics for RivEr Trends (EGRET).
%------------------------------------------------------------ %------------------------------------------------------------
\subsection{What is dataRetrieval?} \subsection{What is dataRetrieval?}
......
...@@ -3,7 +3,22 @@ ...@@ -3,7 +3,22 @@
\alias{FLUX_UNIT} \alias{FLUX_UNIT}
\title{Flux units included in dataRetrieval} \title{Flux units included in dataRetrieval}
\description{ \description{
Flux units Flux units included: \tabular{lllll}{ Number \tab
ObjectName \tab shortName \tab unitFactor \tab unitName
\cr 1 \tab POUNDS_DAY \tab lbs/day \tab 2.204623 \tab
pounds/day\cr 2 \tab TONS_DAY \tab tons/day \tab 0.001102
\tab tons/day \cr 3 \tab KG_DAY \tab kg/day \tab 1 \tab
kg/day \cr 4 \tab THOUSAND_KG_DAY\tab 10^3 kg/day \tab
0.001 \tab "thousands of kg/day\cr 5 \tab TONS_YEAR\tab
tons/yr \tab 0.402619 \tab tons/year\cr 6 \tab
THOUSAND_TONS_YEAR\tab 10^3 tons/yr \tab 0.000402619 \tab
thousands of tons/year \cr 7 \tab MILLION_TONS_YEAR\tab
10^6 tons/yr \tab 4.02619e-07 \tab millions of
tons/year\cr 8 \tab THOUSAND_KG_YEAR\tab 10^3 kg/yr \tab
0.36525 \tab thousands of kg/year\cr 9 \tab
MILLION_KG_YEAR\tab 10^6 kg/yr \tab 0.00036525 \tab
millions of kg/year\cr 10 \tab BILLION_KG_YEAR\tab 10^9
kg/yr \tab 3.6525e-07 \tab billions of kg/year \cr }
} }
\keyword{datasets} \keyword{datasets}
\name{checkStartEndDate}
\alias{checkStartEndDate}
\title{Check Start End Dates}
\usage{
checkStartEndDate(StartDate, EndDate, interactive = TRUE)
}
\arguments{
\item{StartDate}{string date}
\item{EndDate}{string date}
\item{interactive}{logical Option for interactive mode.
If true, there is user interaction for error handling and
data checks.}
}
\value{
list StartDate,EndDate
}
\description{
Checks that the user-supplied starting date is before the
ending date. If not, either the user can re-enter, or
the dates will be set to maximum.
}
\examples{
checkStartEndDate('1985-01-01', '1985-12-31')
}
\keyword{data}
\keyword{from}
\keyword{import}
\keyword{service}
\keyword{web}
\name{dateFormatCheck}
\alias{dateFormatCheck}
\title{Date Formatting Check}
\usage{
dateFormatCheck(date)
}
\arguments{
\item{date}{string date to check}
}
\value{
Date logical
}
\description{
Checks that the user-supplied date is in the format
YYYY-MM-DD and month is less than 13, and dates are less
than 32.
}
\examples{
dateFormatCheck('1985-01-01')
dateFormatCheck('01/01/1985')
}
\keyword{data}
\keyword{from}
\keyword{import}
\keyword{service}
\keyword{web}
\docType{data} \docType{data}
\name{exDaily} \name{exDaily}
\alias{exDaily} \alias{exDaily}
\title{Daily Dataframe included in dataRetrieval} \title{Example Daily Dataframe included in dataRetrieval}
\description{ \description{
Initial Daily data frame from the Choptank River Initial Daily data frame from the Choptank River
} }
......
\docType{data} \docType{data}
\name{exSample} \name{exSample}
\alias{exSample} \alias{exSample}
\title{Sample Dataframe included in dataRetrieval} \title{Example Sample Dataframe included in dataRetrieval}
\description{ \description{
Initial Sample data frame from the Choptank River Initial Sample data frame from the Choptank River
} }
......
\name{formatCheckDate}
\alias{formatCheckDate}
\title{Date Formatting Correction}
\usage{
formatCheckDate(Date, dateString, interactive = TRUE)
}
\arguments{
\item{Date}{string date to check}
\item{dateString}{string should be either 'StartDate' or
'EndDate'}
\item{interactive}{logical Option for interactive mode.
If true, there is user interaction for error handling and
data checks.}
}
\value{
Date string
}
\description{
Checks that the user-supplied date is in the format
YYYY-MM-DD. If not, asks the user to re-enter.
}
\examples{
formatCheckDate('1985-01-01', 'StartDate')
}
\keyword{data}
\keyword{from}
\keyword{import}
\keyword{service}
\keyword{web}
\name{formatCheckParameterCd}
\alias{formatCheckParameterCd}
\title{Parameter Code Check}
\usage{
formatCheckParameterCd(ParameterCd, interactive = TRUE)
}
\arguments{
\item{ParameterCd}{string USGS parameter code}
\item{interactive}{logical Option for interactive mode.
If true, there is user interaction for error handling and
data checks.}
}
\value{
ParameterCd string
}
\description{
Checks that the user-supplied parameter code is 5 digits.
If not, asks the user to re-enter.
}
\examples{
formatCheckParameterCd('00060')
}
\keyword{data}
\keyword{from}
\keyword{import}
\keyword{service}
\keyword{web}
\name{formatCheckSiteNumber}
\alias{formatCheckSiteNumber}
\title{Site number check}
\usage{
formatCheckSiteNumber(siteNumber, interactive = TRUE)
}
\arguments{
\item{siteNumber}{string USGS site number}
\item{interactive}{logical Option for interactive mode.
If true, there is user interaction for error handling and
data checks.}
}
\value{
siteNumber string
}
\description{
Checks that the user-supplied site number is 8 digits,
typical for many USGS station site id's.If not, asks the
user to re-enter. The final siteNumber can be more or
less than 8 digits, since there are conditions where that
is the case.
}
\examples{
formatCheckSiteNumber('01594440')
formatCheckSiteNumber('015944400',interactive=FALSE)
}
\keyword{checking}
\keyword{data}
\keyword{error}
\keyword{for}
\keyword{from}
\keyword{import}
\keyword{service}
\keyword{web}
\name{retrieveNWISData} \name{retrieveNWISData}
\alias{retrieveNWISData} \alias{retrieveNWISData}
\title{Data Import for USGS NWIS Data} \title{Raw Data Import for USGS NWIS Data}
\usage{ \usage{
retrieveNWISData(siteNumber, ParameterCd, StartDate, retrieveNWISData(siteNumber, ParameterCd, StartDate,
EndDate, StatCd = "00003", interactive = TRUE) EndDate, StatCd = "00003", interactive = TRUE)
......
\name{retrieveUnitNWISData} \name{retrieveUnitNWISData}
\alias{retrieveUnitNWISData} \alias{retrieveUnitNWISData}
\title{Data Import for Instantaneous USGS NWIS Data} \title{Raw Data Import for Instantaneous USGS NWIS Data}
\usage{ \usage{
retrieveUnitNWISData(siteNumber, ParameterCd, StartDate, retrieveUnitNWISData(siteNumber, ParameterCd, StartDate,
EndDate, interactive = TRUE) EndDate, interactive = TRUE)
......
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