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

Fixed examples and eval of match.call.

parent 8f9524cc
No related branches found
No related tags found
1 merge request!4added eval to match.call functions.
Package: dataRetrieval
Type: Package
Title: Retrieval functions for hydrologic data
Version: 1.3.2
Version: 1.3.3
Date: 2014-08-04
Author: Robert M. Hirsch, Laura De Cicco
Maintainer: Laura De Cicco <ldecicco@usgs.gov>
......
......@@ -9,9 +9,8 @@
#' (subsequent qualifier/value columns could follow depending on requested parameter codes)
#' @export
#' @examples
#' setInternet2(use=NA)
#' options(timeout=120)
#' pHData <- getGeneralWQPData(siteid="USGS-04024315",characteristicName="pH")
#' nameToUse <- "pH"
#' pHData <- getGeneralWQPData(siteid="USGS-04024315",characteristicName=nameToUse)
getGeneralWQPData <- function(...){
matchReturn <- match.call()
......@@ -22,7 +21,7 @@ getGeneralWQPData <- function(...){
if(!all(names(matchReturn[-1]) %in% options)) warning(matchReturn[!(names(matchReturn[-1]) %in% options)],"is not a valid query parameter to the Water Quality Portal")
values <- sapply(matchReturn[-1], function(x) URLencode(as.character(paste(x,collapse="",sep=""))))
values <- sapply(matchReturn[-1], function(x) URLencode(as.character(paste(eval(x),collapse="",sep=""))))
urlCall <- paste(paste(names(values),values,sep="="),collapse="&")
......
......@@ -13,7 +13,7 @@ getNWISSites <- function(...){
matchReturn <- match.call()
values <- sapply(matchReturn[-1], function(x) URLencode(as.character(paste(x,collapse="",sep=""))))
values <- sapply(matchReturn[-1], function(x) URLencode(as.character(paste(eval(x),collapse="",sep=""))))
urlCall <- paste(paste(names(values),values,sep="="),collapse="&")
......
......@@ -9,13 +9,10 @@
#' (subsequent qualifier/value columns could follow depending on requested parameter codes)
#' @export
#' @examples
#' setInternet2(use=NA)
#' options(timeout=120)
#' \dontrun{sitesList <- getWQPSites(within=10,lat=43.06932,long=-89.4444,characteristicName="pH")
#' siteListPH <- getWQPSites(characteristicName="pH")}
#' siteListPH <- getWQPSites(characteristicName="pH", statecode="US:55")
getWQPSites <- function(...){
matchReturn <- match.call()
matchReturn <- match.call(expand.dots = TRUE)
options <- c("bBox","lat","long","within","countrycode","statecode","countycode","siteType","organization",
"siteid","huc","sampleMedia","characteristicType","characteristicName","pCode","activityId",
......@@ -23,7 +20,7 @@ getWQPSites <- function(...){
if(!all(names(matchReturn[-1]) %in% options)) warning(matchReturn[!(names(matchReturn[-1]) %in% options)],"is not a valid query parameter to the Water Quality Portal")
values <- sapply(matchReturn[-1], function(x) URLencode(as.character(paste(x,collapse="",sep=""))))
values <- sapply(matchReturn[-1], function(x) URLencode(as.character(paste(eval(x),collapse="",sep=""))))
urlCall <- paste(paste(names(values),values,sep="="),collapse="&")
......
......@@ -6,7 +6,7 @@
#' @return DateFrame dataframe
#' @export
#' @examples
#' dateTime <- c('1984-01-01', '1985-01-02', '1986-01-03')
#' dateTime <- c('1984-02-28 13:56', '1984-03-01', '1986-03-01')
#' expandedDateDF <- populateDateColumns(dateTime)
populateDateColumns <- function(rawData){ # rawData is a vector of dates
DateFrame <- as.data.frame(matrix(ncol=1,nrow=length(rawData)))
......@@ -17,12 +17,25 @@ populateDateColumns <- function(rawData){ # rawData is a vector of dates
DateFrame$Month <- dateTime$mon + 1
DateFrame$Day <- dateTime$yday + 1
year <- dateTime$year + 1900
hour <- dateTime$hour
minute <- dateTime$min
if (sum(hour) == 0 & sum(minute) == 0){
dateTime$hour <- rep(12,length(dateTime))
}
leapOffset <- ifelse((year%%4 == 0) & ((year%%100 != 0) | (year%%400 == 0)), 0,1)
DateFrame$Day[DateFrame$Day > 59] <- DateFrame$Day[DateFrame$Day > 59] + leapOffset[DateFrame$Day > 59]
DateFrame$DecYear <- year + (DateFrame$Day -0.5)/366
# DateFrame$DecYear <- year + (DateFrame$Day -0.5)/366
jan1 <- as.POSIXlt(paste(year,"-01-01",sep=""),format="%Y-%m-%d")
jan1NextYear <- as.POSIXlt(paste(year+1,"-01-01",sep=""),format="%Y-%m-%d")
decimal <- as.numeric(difftime(dateTime, jan1, units = "secs"))
decimal <- decimal/as.numeric(difftime(jan1NextYear, jan1, units = "secs"))
DateFrame$DecYear <- year + decimal
DateFrame$MonthSeq <- ((year-1850)*12)+DateFrame$Month
return (DateFrame)
......
......@@ -17,9 +17,8 @@ Imports data from Water Quality Portal web service. This function gets the data
because it allows for other agencies rather than the USGS.
}
\examples{
setInternet2(use=NA)
options(timeout=120)
pHData <- getGeneralWQPData(siteid="USGS-04024315",characteristicName="pH")
nameToUse <- "pH"
pHData <- getGeneralWQPData(siteid="USGS-04024315",characteristicName=nameToUse)
}
\keyword{WQP}
\keyword{data}
......
......@@ -17,10 +17,7 @@ Returns a list of sites from the Water Quality Portal web service. This function
Arguments to the function should be based on \url{www.waterqualitydata.us/webservices_documentation.jsp}
}
\examples{
setInternet2(use=NA)
options(timeout=120)
\dontrun{sitesList <- getWQPSites(within=10,lat=43.06932,long=-89.4444,characteristicName="pH")
siteListPH <- getWQPSites(characteristicName="pH")}
siteListPH <- getWQPSites(characteristicName="pH", statecode="US:55")
}
\keyword{WQP}
\keyword{data}
......
......@@ -15,7 +15,7 @@ DateFrame dataframe
Creates various date columns for WRTDS study.
}
\examples{
dateTime <- c('1984-01-01', '1985-01-02', '1986-01-03')
dateTime <- c('1984-02-28 13:56', '1984-03-01', '1986-03-01')
expandedDateDF <- populateDateColumns(dateTime)
}
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (MiKTeX 2.9) (preloaded format=pdflatex 2014.8.7) 8 AUG 2014 15:39
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (MiKTeX 2.9) (preloaded format=pdflatex 2014.8.7) 13 AUG 2014 13:08
entering extended mode
**dataRetrieval.tex
(D:\LADData\RCode\dataRetrieval\vignettes\dataRetrieval.tex
......@@ -1022,7 +1022,7 @@ les (x86)/MiKTeX 2.9/fonts/type1/urw/courier/ucrb8a.pfb><C:/Program Files (x86)
rw/helvetic/uhvr8a.pfb><C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/urw/times
/utmr8a.pfb><C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/urw/times/utmri8a.pf
b>
Output written on dataRetrieval.pdf (33 pages, 335873 bytes).
Output written on dataRetrieval.pdf (33 pages, 335831 bytes).
PDF statistics:
484 PDF objects out of 1000 (max. 8388607)
84 named destinations out of 1000 (max. 500000)
......
No preview for this file type
No preview for this file type
......@@ -267,7 +267,7 @@ Not every station will measure all parameters. A short list of commonly measured
% latex table generated in R 3.1.1 by xtable 1.7-3 package
% Fri Aug 08 15:39:28 2014
% Wed Aug 13 13:07:49 2014
\begin{table}[ht]
\caption{Common USGS Parameter Codes}
\label{tab:params}
......@@ -330,7 +330,7 @@ For unit values data (sensor data measured at regular time intervals such as 15
Some common codes are shown in Table \ref{tab:stat}.
% latex table generated in R 3.1.1 by xtable 1.7-3 package
% Fri Aug 08 15:39:30 2014
% Wed Aug 13 13:07:50 2014
\begin{table}[ht]
\caption{Commonly used USGS Stat Codes}
\label{tab:stat}
......@@ -411,7 +411,7 @@ To discover what data is available for a particular USGS site, including measure
% latex table generated in R 3.1.1 by xtable 1.7-3 package
% Fri Aug 08 15:39:30 2014
% Wed Aug 13 13:07:50 2014
\begin{table}[ht]
\caption{Daily mean data availabile at the Choptank River near Greensboro, MD. [Some columns deleted for space considerations]}
\label{tab:gda}
......@@ -423,7 +423,7 @@ To discover what data is available for a particular USGS site, including measure
& Temperature, water & 1988-10-01 & 2012-05-09 & 894 & deg C \\
[5pt] & Temperature, water & 2010-10-01 & 2012-05-09 & 529 & deg C \\
[5pt] & Temperature, water & 2010-10-01 & 2012-05-09 & 529 & deg C \\
[5pt] & Stream flow, mean. daily & 1948-01-01 & 2014-08-07 & 24326 & ft$^3$/s \\
[5pt] & Stream flow, mean. daily & 1948-01-01 & 2014-08-12 & 24331 & ft$^3$/s \\
[5pt] & Specific conductance & 2010-10-01 & 2012-05-09 & 527 & uS/cm @25C \\
[5pt] & Specific conductance & 2010-10-01 & 2012-05-09 & 527 & uS/cm @25C \\
[5pt] & Specific conductance & 2010-10-01 & 2012-05-09 & 527 & uS/cm @25C \\
......@@ -789,7 +789,7 @@ There are 4750 data points, and 4750 days.
% latex table generated in R 3.1.1 by xtable 1.7-3 package
% Fri Aug 08 15:39:49 2014
% Wed Aug 13 13:08:05 2014
\begin{table}[ht]
\caption{Daily dataframe}
\label{tab:DailyDF1}
......@@ -910,7 +910,7 @@ To illustrate how the dataRetrieval package handles a more complex censoring pro
% latex table generated in R 3.1.1 by xtable 1.7-3 package
% Fri Aug 08 15:39:50 2014
% Wed Aug 13 13:08:06 2014
\begin{table}[ht]
\caption{Example data}
\label{tab:exampleComplexQW}
......@@ -955,12 +955,12 @@ For the more complex example case, let us say dp is reported as \verb@<@0.01 and
5 2005-05-30 NA 0.050 0 0.0250 56762 5
6 2005-10-30 NA 0.020 0 0.0100 56915 10
Day DecYear MonthSeq SinDY CosDY
1 46 2003 1838 0.70407 0.7101
2 182 2003 1842 0.02575 -0.9997
3 259 2005 1857 -0.96251 -0.2712
4 30 2005 1861 0.48506 0.8745
5 151 2005 1865 0.52943 -0.8484
6 304 2006 1870 -0.87861 0.4775
1 46 2003 1838 0.70253 0.7117
2 182 2003 1842 0.03872 -0.9993
3 259 2005 1857 -0.96134 -0.2754
4 30 2005 1861 0.48251 0.8759
5 151 2005 1865 0.54163 -0.8406
6 304 2006 1870 -0.88205 0.4712
\end{verbatim}
\end{kframe}
\end{knitrout}
......@@ -1122,12 +1122,12 @@ There are 4750 data points, and 4750 days.
5 2000-03-23 56.917 4.0416 0.52 0.52 1 0.52
6 2000-06-05 1.812 0.5946 1.11 1.11 1 1.11
Julian Month Day DecYear MonthSeq SinDY CosDY
1 54789 1 4 2000 1801 0.06005 0.9982
2 54819 2 34 2000 1802 0.54392 0.8391
3 54831 2 46 2000 1802 0.70407 0.7101
4 54835 2 50 2000 1802 0.75113 0.6602
5 54868 3 83 2000 1803 0.98809 0.1539
6 54942 6 157 2000 1806 0.43940 -0.8983
1 54789 1 4 2000 1801 0.05576 0.9984
2 54819 2 34 2000 1802 0.54031 0.8415
3 54831 2 46 2000 1802 0.70101 0.7132
4 54835 2 50 2000 1802 0.74829 0.6634
5 54868 3 83 2000 1803 0.98742 0.1581
6 54942 6 157 2000 1806 0.44325 -0.8964
\end{verbatim}
\end{kframe}
\end{knitrout}
......@@ -1351,7 +1351,7 @@ There are a few steps that are required in order to create a table in a Microsof
5 Suspended sediment discharge 1980-10-01
End Count Units
1 2012-05-09 529 deg C
2 2014-08-07 24326 ft3/s
2 2014-08-12 24331 ft3/s
3 2012-05-09 527 uS/cm @25C
4 1991-09-30 3651 mg/l
5 1991-09-30 3652 tons/day
......
No preview for this file type
No preview for this file type
No preview for this file type
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