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

Updated examples to not use interactive=FALSE. Rebuilt package.

parent c3d90cb4
No related branches found
No related tags found
No related merge requests found
......@@ -62,7 +62,8 @@ Depends:
Imports:
zoo,
XML,
RCurl
RCurl,
plyr
Suggests:
xtable,
EGRET,
......
......@@ -43,3 +43,4 @@ export(retrieveUnitNWISData)
import(RCurl)
import(XML)
import(zoo)
importFrom(plyr,rbind.fill.matrix)
......@@ -11,7 +11,7 @@
#' @examples
#' startDate <- '1985-01-01'
#' endDate <- '1990-01-01'
#' checkStartEndDate(startDate, endDate, interactive = FALSE)
#' checkStartEndDate(startDate, endDate)
checkStartEndDate <- function(StartDate, EndDate,interactive=TRUE){
start <- as.Date("1850-01-01")
end <- as.Date(Sys.Date())
......
......@@ -20,7 +20,7 @@
#' comment3 <- c("","","<")
#' value3 <- c(3,4,5)
#' dataInput <- data.frame(dateTime, comment1, value1, comment2, value2, comment3, value3, stringsAsFactors=FALSE)
#' compressData(dataInput, interactive=FALSE)
#' compressData(dataInput)
compressData <- function(data, interactive=TRUE){
data <- as.data.frame(data, stringsAsFactors=FALSE)
......
......@@ -13,7 +13,7 @@
#' @param format string, can be "tsv" or "xml", and is only applicable for daily and unit value requests. "tsv" returns results faster, but there is a possiblitiy that an incomplete file is returned without warning. XML is slower,
#' but will offer a warning if the file was incomplete (for example, if there was a momentary problem with the internet connection). It is possible to safely use the "tsv" option,
#' but the user must carefully check the results to see if the data returns matches what is expected. The default is therefore "xml".
#' @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.
#' @keywords data import USGS web service
#' @return url string
#' @export
......@@ -28,7 +28,7 @@
#' url_qw <- constructNWISURL(siteNumber,c('01075','00029','00453'),startDate,endDate,'qw')
#' url_wqp <- constructNWISURL(siteNumber,c('01075','00029','00453'),startDate,endDate,'wqp')
#' url_daily_tsv <- constructNWISURL(siteNumber,pCode,startDate,endDate,'dv',statCd=c("00003","00001"),format="tsv")
constructNWISURL <- function(siteNumber,parameterCd,startDate,endDate,service,statCd="00003", format="xml",interactive=FALSE){
constructNWISURL <- function(siteNumber,parameterCd,startDate,endDate,service,statCd="00003", format="xml",interactive=TRUE){
startDate <- formatCheckDate(startDate, "StartDate", interactive=interactive)
endDate <- formatCheckDate(endDate, "EndDate", interactive=interactive)
......
......@@ -9,7 +9,7 @@
#' @export
#' @examples
#' pCode <- '01234'
#' formatCheckParameterCd(pCode, interactive = FALSE)
#' formatCheckParameterCd(pCode)
formatCheckParameterCd <- function(ParameterCd, interactive=TRUE){ #checks for a 5 digit number
pCodeReturn <- rep(NA,length(ParameterCd))
......
......@@ -8,7 +8,7 @@
#' @export
#' @examples
#' site<- '01234567'
#' formatCheckSiteNumber(site, interactive = FALSE)
#' formatCheckSiteNumber(site)
formatCheckSiteNumber <- function(siteNumber, interactive=TRUE){ #checks for a 8 digit number
if (nchar(siteNumber) != 8){
if (interactive){
......
......@@ -20,7 +20,7 @@
#' @seealso \code{\link{retrieveNWISData}}, \code{\link{populateDaily}}
#' @examples
#' # 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')
getDVData <- function (siteNumber,ParameterCd,StartDate,EndDate,interactive=TRUE,convert=TRUE,format="tsv"){
data <- retrieveNWISData(siteNumber,ParameterCd,StartDate,EndDate,interactive=interactive,format=format)
......
......@@ -9,7 +9,7 @@
#' @export
#' @examples
#' # These examples require an internet connection to run
#' availableData <- getDataAvailability('05114000',interactive=FALSE)
#' availableData <- getDataAvailability('05114000')
getDataAvailability <- function(siteNumber="",interactive=TRUE){
# Checking for 8 digit site ID:
......
......@@ -14,9 +14,9 @@
#' @examples
#' # Examples of how to use getDataFromFile:
#' # Change the file path and file name to something meaningful:
#' #filePath <- '~/RData/' # Sample format
#' filePath <- '~/RData/' # Sample format
#' fileName <- 'ChoptankRiverFlow.txt'
#' #getDataFromFile(filePath,fileName, separator="\t")
#' \dontrun{getDataFromFile(filePath,fileName, separator="\t")}
getDataFromFile <- function (filePath,fileName,hasHeader=TRUE,separator=","){
totalPath <- paste(filePath,fileName,sep="");
tmp <- read.delim(
......
......@@ -17,7 +17,7 @@
#' @examples
#' # These examples require an internet connection to run
#' # Automatically gets information about site 05114000 and temperature, no interaction with user
#' INFO <- getMetaData('05114000','00010',interactive=FALSE)
#' INFO <- getMetaData('05114000','00010')
getMetaData <- function(siteNumber="", parameterCd="",interactive=TRUE){
if (nzchar(siteNumber)){
INFO <- getSiteFileData(siteNumber,interactive=interactive)
......
......@@ -17,7 +17,7 @@
#' # These examples require an internet connection to run
#' rawProcessedSample <- getQWData('01594440','01075', '1985-01-01', '1985-03-31')
#' rawProcessedSampleAll <- getQWData('05114000','', '1985-01-01', '1985-03-31')
#' rawProcessedSampleSelect <- getQWData('05114000','00915;00931', '1985-01-01', '1985-04-30', interactive=FALSE)
#' rawProcessedSampleSelect <- getQWData('05114000','00915;00931', '1985-01-01', '1985-04-30')
getQWData <- function(siteNumber,ParameterCd,StartDate,EndDate,interactive=TRUE){
rawSample <- getRawQWData(siteNumber,ParameterCd,StartDate,EndDate,interactive)
retval <- processQWData(rawSample)
......
......@@ -17,7 +17,7 @@
#' # Change the file path and file name to something meaningful:
#' filePath <- '~/RData/' # Sample format
#' fileName <- 'ChoptankRiverNitrate.csv'
#' #rawSampleData <- getQWDataFromFile(filePath,fileName, separator=";")
#' \dontrun{rawSampleData <- getQWDataFromFile(filePath,fileName, separator=";")}
getQWDataFromFile <- function (filePath,fileName,hasHeader=TRUE,separator=","){
totalPath <- paste(filePath,fileName,sep="");
tmp <- read.delim(
......
......@@ -5,7 +5,7 @@
#' A list of statistic codes can be found here: \url{http://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table}
#'
#' @param siteNumber string USGS site number. This is usually an 8 digit number
#' @param ParameterCd string USGS parameter code. This is usually an 5 digit number. Multiple parameter codes can be inputted with a ';' separator. Leaving this blank will return all of the measured values during the specified time period.
#' @param ParameterCd vector of USGS 5-digit parameter code. Leaving this blank will return all of the measured values during the specified time period.
#' @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.
......@@ -18,7 +18,7 @@
#' # These examples require an internet connection to run
#' rawSample <- getRawQWData('01594440','01075', '1985-01-01', '1985-03-31')
#' rawSampleAll <- getRawQWData('05114000','', '1985-01-01', '1985-03-31')
#' rawSampleSelect <- getRawQWData('05114000',c('00915','00931'), '1985-01-01', '1985-04-30', interactive=FALSE)
#' rawSampleSelect <- getRawQWData('05114000',c('00915','00931'), '1985-01-01', '1985-04-30')
getRawQWData <- function(siteNumber,ParameterCd,StartDate,EndDate,interactive=TRUE){
url <- constructNWISURL(siteNumber,ParameterCd,StartDate,EndDate,"wqp")
......
......@@ -17,8 +17,8 @@
#' @seealso \code{\link{compressData}}, \code{\link{populateSampleColumns}}
#' @examples
#' # These examples require an internet connection to run
#' Sample_01075 <- getSTORETSampleData('USGS-01594440','Chloride', '', '', interactive=FALSE)
#' Sample_All <- getSTORETSampleData('WIDNR_WQX-10032762','Specific conductance', '', '', interactive=FALSE)
#' Sample_01075 <- getSTORETSampleData('USGS-01594440','Chloride', '', '')
#' Sample_All <- getSTORETSampleData('WIDNR_WQX-10032762','Specific conductance', '', '')
getSTORETSampleData <- function(siteNumber,characteristicName,StartDate,EndDate,interactive=TRUE){
data <- getWQPData(siteNumber,characteristicName,StartDate,EndDate,interactive=interactive)
compressedData <- compressData(data, interactive=interactive)
......
......@@ -17,9 +17,9 @@
#' @seealso \code{\link{compressData}}, \code{\link{populateSampleColumns}}
#' @examples
#' # These examples require an internet connection to run
#' Sample_01075 <- getSampleData('01594440','01075', '1985-01-01', '1985-03-31', interactive=FALSE)
#' Sample_All <- getSampleData('05114000','00915;00931', '1985-01-01', '1985-03-31', interactive=FALSE)
#' Sample_Select <- getSampleData('05114000','00915;00931', '', '', interactive=FALSE)
#' Sample_01075 <- getSampleData('01594440','01075', '1985-01-01', '1985-03-31')
#' Sample_All <- getSampleData('05114000','00915;00931', '1985-01-01', '1985-03-31')
#' Sample_Select <- getSampleData('05114000','00915;00931', '', '')
getSampleData <- function(siteNumber,ParameterCd,StartDate,EndDate,interactive=TRUE){
data <- getQWData(siteNumber,ParameterCd,StartDate,EndDate,interactive=interactive)
compressedData <- compressData(data, interactive=interactive)
......
......@@ -16,7 +16,7 @@
#' # Change the file path and file name to something meaningful:
#' filePath <- '~/RData/' # Sample format
#' fileName <- 'ChoptankRiverNitrate.csv'
#' #Sample <- getSampleDataFromFile(filePath,fileName, separator=";",interactive=FALSE)
#' \dontrun{Sample <- getSampleDataFromFile(filePath,fileName, separator=";",interactive=FALSE)}
getSampleDataFromFile <- function (filePath,fileName,hasHeader=TRUE,separator=",", interactive=TRUE){
data <- getQWDataFromFile(filePath,fileName,hasHeader=hasHeader,separator=separator)
compressedData <- compressData(data, interactive=interactive)
......
......@@ -9,7 +9,7 @@
#' @export
#' @examples
#' # These examples require an internet connection to run
#' siteINFO <- getSiteFileData('05114000',interactive=FALSE)
#' siteINFO <- getSiteFileData('05114000')
getSiteFileData <- function(siteNumber="",interactive=TRUE){
# Checking for 8 digit site ID:
......
#' Function to return data from the NWISWeb WaterML1.1 daily values service
#' Function to return data from the NWISWeb WaterML1.1 service
#'
#' This function accepts a url parameter that already contains the desired
#' NWIS site, parameter code, statistic, startdate and enddate.
......
......@@ -6,14 +6,10 @@
#' @return mergedDF a data frame containing columns agency, site, dateTime, values, and remark codes for all requested combinations
#' @export
#' @import XML
#' @import plyr
#' @importFrom plyr rbind.fill.matrix
#' @examples
#' url <- "http://webvastage6.er.usgs.gov/ogc-swie/wml2/uv/sos?request=GetObservation&featureID=01446500&observedProperty=00065&offering=UNIT&beginPosition=2013-08-20"
#' dataReturned <- getWaterML2Data(url)
#' URL2 <- "http://cida-test.er.usgs.gov/ngwmn_cache/sos?REQUEST=GetObservation&featureOfInterest=VW_GWDP_GEOSERVER.USGS.401532085085301"
#' dataReturned2 <- getWaterML2Data(URL2)
#' URL3 <- "http://webvastage6.er.usgs.gov/ogc-swie/wml2/dv/sos?request=GetObservation&featureID=435601087432701&observedProperty=00045&beginPosition=2012-01-01&offering=Sum"
#' dataReturned3 <- getWaterML2Data(URL3)
#' URL <- "http://webvastage6.er.usgs.gov/ogc-swie/wml2/dv/sos?request=GetObservation&featureID=435601087432701&observedProperty=00045&beginPosition=2012-01-01&offering=Sum"
#' dataReturned3 <- getWaterML2Data(URL)
getWaterML2Data <- function(obs_url){
doc <- xmlTreeParse(obs_url, getDTD = FALSE, useInternalNodes = TRUE)
......@@ -27,7 +23,7 @@ getWaterML2Data <- function(obs_url){
setNames(ifelse(nzchar(xmlValue(x)), xmlValue(x),
ifelse("qualifier" == xmlName(x),xpathSApply(x,"./@xlink:title",namespaces = ns),"")), #originally I had the "" as xmlAttr(x)
xmlName(x)), namespaces = ns)
library(plyr)
DF2 <- do.call(rbind.fill.matrix, lapply(xp, t))
DF2 <- as.data.frame(DF2,stringsAsFactors=FALSE)
DF2$time <- gsub(":","",DF2$time)
......
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