diff --git a/inst/doc/Rplots.pdf b/inst/doc/Rplots.pdf deleted file mode 100644 index c7bd0c52586c29ab96ac024c50eb96527a2f94a8..0000000000000000000000000000000000000000 Binary files a/inst/doc/Rplots.pdf and /dev/null differ diff --git a/inst/doc/dataRetrieval-concordance.tex b/inst/doc/dataRetrieval-concordance.tex deleted file mode 100644 index 6666b7b667561fba80b016bbd472f5700fae6068..0000000000000000000000000000000000000000 --- a/inst/doc/dataRetrieval-concordance.tex +++ /dev/null @@ -1,16 +0,0 @@ -\Sconcordance{concordance:dataRetrieval.tex:dataRetrieval.Rnw:% -1 84 1 1 8 1 1 1 10 16 0 1 2 5 1 1 10 15 0 1 2 13 1 1 2 1 0 1 2 1 0 1 1 % -3 0 1 2 2 1 1 2 7 0 1 2 7 1 1 3 2 0 1 1 12 0 1 2 5 1 1 4 3 0 1 3 1 0 1 % -3 7 0 1 3 4 0 1 2 2 1 1 8 7 0 1 4 1 0 1 2 21 0 1 2 7 1 1 3 2 0 2 1 7 0 % -1 2 1 1 1 2 7 0 1 2 9 1 1 4 2 0 2 1 1 2 3 0 1 2 4 1 1 3 1 0 3 1 1 3 5 0 % -1 3 4 1 1 2 1 0 1 4 3 0 1 1 1 4 3 0 3 1 3 0 1 2 3 1 1 -5 1 9 14 1 1 3 1 % -0 1 1 1 2 1 0 1 3 5 0 2 2 10 0 1 2 3 1 1 2 1 0 1 4 3 0 1 1 4 0 1 3 3 1 % -1 -6 1 10 12 1 1 4 2 0 2 1 1 3 1 0 1 3 1 0 1 1 7 0 1 2 1 1 1 6 5 0 1 1 % -3 0 1 2 2 1 1 -4 1 8 11 1 1 3 2 0 1 1 12 0 1 2 8 1 1 3 2 0 5 1 3 0 1 2 % -13 1 1 2 1 0 1 1 3 0 1 2 8 1 1 2 1 0 2 1 1 3 5 0 1 2 2 1 1 11 18 0 1 2 % -9 1 1 3 5 0 1 2 2 1 1 12 24 0 1 2 11 1 1 14 12 0 1 2 9 1 1 2 17 0 1 3 % -28 1 1 2 1 0 2 1 3 0 1 2 16 1 1 2 1 0 2 1 3 0 1 2 7 1 1 2 1 0 3 1 1 2 2 % -1 11 0 1 1 19 0 1 2 6 1 1 3 2 0 1 1 3 0 1 2 3 1 1 -5 1 9 21 1 1 2 4 0 1 % -2 1 1 1 2 13 0 1 2 6 1 1 2 1 0 1 1 3 0 1 2 3 1 1 2 4 0 1 2 7 1 1 2 1 0 % -1 1 3 0 1 2 1 1 1 2 4 0 1 2 10 1 1 5 47 0 1 2 9 1 1 6 45 0 1 2 2 1 1 6 % -27 0 1 2 8 1 1 2 1 0 4 1 1 9 10 0 1 2 3 1 1 3 5 0 1 2 53 1} diff --git a/inst/doc/dataRetrieval-fig1.pdf b/inst/doc/dataRetrieval-fig1.pdf deleted file mode 100644 index 189c7911b1b65a4d6965c0d44bf23e0c4a113f81..0000000000000000000000000000000000000000 Binary files a/inst/doc/dataRetrieval-fig1.pdf and /dev/null differ diff --git a/inst/doc/dataRetrieval-fig2.pdf b/inst/doc/dataRetrieval-fig2.pdf deleted file mode 100644 index cfa370908d52f8ee543c8fc0d6a24c7e612820a2..0000000000000000000000000000000000000000 Binary files a/inst/doc/dataRetrieval-fig2.pdf and /dev/null differ diff --git a/inst/doc/dataRetrieval-fig3.pdf b/inst/doc/dataRetrieval-fig3.pdf deleted file mode 100644 index 86bfd5026060e1a19c65883ce3171a29a083cd5c..0000000000000000000000000000000000000000 Binary files a/inst/doc/dataRetrieval-fig3.pdf and /dev/null differ diff --git a/inst/doc/dataRetrieval-figegretEx.pdf b/inst/doc/dataRetrieval-figegretEx.pdf deleted file mode 100644 index 942c655a6d171bf720c075494ac584c8f7e55285..0000000000000000000000000000000000000000 Binary files a/inst/doc/dataRetrieval-figegretEx.pdf and /dev/null differ diff --git a/inst/doc/dataRetrieval.Rnw b/inst/doc/dataRetrieval.Rnw deleted file mode 100644 index a92f5947bfd6a56788a3cc14de45b9d77645a18e..0000000000000000000000000000000000000000 --- a/inst/doc/dataRetrieval.Rnw +++ /dev/null @@ -1,818 +0,0 @@ -%\VignetteIndexEntry{Introduction to the dataRetrieval package} -%\VignetteDepends{} -%\VignetteSuggests{} -%\VignetteImports{} -%\VignettePackage{} - -\documentclass[a4paper,11pt]{article} - -\usepackage{amsmath} -\usepackage{times} -\usepackage{hyperref} -\usepackage[numbers, round]{natbib} -\usepackage[american]{babel} -\usepackage{authblk} -\usepackage{footnote} -\usepackage{placeins} -\renewcommand\Affilfont{\itshape\small} -\usepackage{Sweave} -\renewcommand{\topfraction}{0.85} -\renewcommand{\textfraction}{0.1} -\usepackage{graphicx} - - -\textwidth=6.2in -\textheight=8.5in -\parskip=.3cm -\oddsidemargin=.1in -\evensidemargin=.1in -\headheight=-.3in - -%------------------------------------------------------------ -% newcommand -%------------------------------------------------------------ -\newcommand{\scscst}{\scriptscriptstyle} -\newcommand{\scst}{\scriptstyle} -\newcommand{\Robject}[1]{{\texttt{#1}}} -\newcommand{\Rfunction}[1]{{\texttt{#1}}} -\newcommand{\Rclass}[1]{\textit{#1}} -\newcommand{\Rpackage}[1]{\textit{#1}} -\newcommand{\Rexpression}[1]{\texttt{#1}} -\newcommand{\Rmethod}[1]{{\texttt{#1}}} -\newcommand{\Rfunarg}[1]{{\texttt{#1}}} - -\begin{document} -\SweaveOpts{concordance=TRUE} - -%------------------------------------------------------------ -\title{The dataRetrieval R package} -%------------------------------------------------------------ -\author[1]{Laura De Cicco} -\author[1]{Robert Hirsch} -\affil[1]{United States Geological Survey} - -\SweaveOpts{highlight=TRUE, tidy=TRUE, keep.space=TRUE, keep.blank.space=FALSE, keep.comment=TRUE, keep.source=TRUE} - -\maketitle -\tableofcontents - -%------------------------------------------------------------ -\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 R package: Exploration and Graphics for RivEr Trends (EGRET). See: \url{https://github.com/USGS-R/EGRET/wiki} for information on EGRET. EGRET is designed to provide analysis of water quality data sets using the WRTDS method of data analysis (WRTDS is Weighted Regressions on Time, Discharge and Season) as well as analysis of streamflow trends using robust time-series smoothing techniques. Both of these capabilities provide both tabular and graphical analyses of long-term data sets. - - -The dataRetrieval package is designed to retrieve many of the major data types of USGS hydrologic data that are available on the web, but also allows users to make use of other data that they supply from spreadsheets. Section 2 provides examples of how one can obtain raw data from USGS sources on the web and ingest them into data frames within the R environment. The functionality described in section 2 is for general use and is not tailored for the specific uses of the EGRET package. The functionality described in section 3 is tailored specifically to obtaining input from the web and structuring them specifically for use in the EGRET package. The functionality described in section 4 is for converting hydrologic data from user-supplied spreadsheets and structuring them specifically for use in the EGRET package. - -For information on getting started in R and installing the package, see Appendix (\ref{sec:appendix1}): Getting Started. - - -%------------------------------------------------------------ -\section{General USGS Web Retrievals} -%------------------------------------------------------------ -In this section, we will run through 5 examples, documenting how to get raw data from the web. This includes site information (\ref{sec:usgsSite}), measured parameter information (\ref{sec:usgsParams}), historical daily values(\ref{sec:usgsDaily}), real-time (unit) values (\ref{sec:usgsRT}), and water quality data (\ref{sec:usgsWQP}) or (\ref{sec:usgsSTORET}). We will use the Choptank River near Greensboro, MD as an example. The site-ID for this gage station is 01491000. Daily discharge measurements are available as far back as 1948. Additionally, forms of nitrate have been measured dating back to 1964. The functions/examples in this section are for raw data retrieval. This may or may not be the easiest data to work with. In the next section, we will use functions that retrieve and process the data in a dataframe that may prove more friendly for R analysis. - -%------------------------------------------------------------ -\subsection{Introduction} -%------------------------------------------------------------ -The United States Geological Survey organizes their hydrological data in standard structure. Streamgages are located throughout the United States, and each streamgage has a unique ID. Often (but not always), these ID's are 8 digits. The first step to finding data is discoving this 8-digit ID. One potential tool for discovering data is Environmental Data Discovery and Transformation (EnDDaT): \url{http://cida.usgs.gov/enddat/}. Follow the example on the EnDDaT web page to learn how to discover USGS stations and available data from any location in the United States. - -Once the site-ID is known, the next required input for USGS data retrievals is the 'parameter code'. This is a 5-digit code that specifies what measured paramater is being requested. A complete list of possible USGS parameter codes can be found at: - -\url{http://nwis.waterdata.usgs.gov/usa/nwis/pmcodes?radio_pm_search=param_group&pm_group=All+--+include+all+parameter+groups&pm_search=&casrn_search=&srsname_search=&format=html_table&show=parameter_group_nm&show=parameter_nm&show=casrn&show=srsname&show=parameter_units} - -Not every station will measure all parameters. A short list of commonly measured parameters is shown in Table \ref{tab:params}. - -<<openLibrary, echo=FALSE>>= -library(xtable) -options(continue=" ") -# options(width=60) -# options(SweaveHooks=list(fig=function() -# par(mar=c(4.1,4.1,1.1,4.1),oma=c(0,0,0,0)))) -@ - - -<<label=tableParameterCodes, echo=FALSE,results=tex>>= -pCode <- c('00060', '00065', '00010','00045','00400') -shortName <- c("Discharge [cfs]","Gage height [ft]","Temperature [C]", "Precipitation [in]", "pH") - -data.df <- data.frame(pCode, shortName, stringsAsFactors=FALSE) - -data.table <- xtable(data.df,label="tab:params", - caption="Common USGS Parameter Codes") -print(data.table, - caption.placement="top",include.rownames=FALSE, table.placement="!ht") -@ - -For real-time data, the parameter code and site ID will suffice. For most variables that are measured on a continuous basis, the USGS stores the historical data as daily values. These daily values may be in the form of statistics such as the daily mean values, but they can also include daily maximums, minimums or medians. These different statistics are specified by a 5-digit \texttt{"}stat code\texttt{"}. A complete list of stat codes can be found here: - -\url{http://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table} - -Some common stat codes are shown in Table \ref{tab:stat}. -<<label=tableStatCodes, echo=FALSE,results=tex>>= -StatCode <- c('00001', '00002', '00003','00008') -shortName <- c("Maximum","Minimum","Mean", "Median") - -data.df <- data.frame(StatCode, shortName, stringsAsFactors=FALSE) - -data.table <- xtable(data.df,label="tab:stat", - caption="Commonly found USGS Stat Codes") -print(data.table, - caption.placement="top",include.rownames=FALSE, table.placement="!ht") -@ - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Site Information} -\label{sec:usgsSite} -%------------------------------------------------------------ - -%------------------------------------------------------------ -\subsubsection{getSiteFileData} -\label{sec:usgsSiteFileData} -%------------------------------------------------------------ -Use the getSiteFileData function to obtain all of the information available for a particular USGS site such as full station name, drainage area, latitude, and longitude: - - -<<label=getSite, echo=TRUE>>= -library(dataRetrieval) -# Site ID for Choptank River near Greensboro, MD -siteNumber <- "01491000" -ChoptankInfo <- getSiteFileData(siteNumber) -@ - -A list of the available columns are found in Appendix \ref{sec:appendix2INFO}: INFO dataframe. Pulling out a specific example piece of information, in this case station name can be done as follows: - -<<siteNames, echo=TRUE>>= -ChoptankInfo$station.nm -@ -Site information is obtained from \url{http://waterservices.usgs.gov/rest/Site-Test-Tool.html} -\FloatBarrier -%------------------------------------------------------------ -\subsubsection{getDataAvailability} -\label{sec:usgsDataAvailability} -%------------------------------------------------------------ -To find out the available data at a particular USGS site, including measured parameters, period of record, and number of samples (count), use the getDataAvailability function: - -<<label=getSiteAvailability, echo=TRUE>>= -# Continuing from the previous example: -ChoptankAvailableData <- getDataAvailability(siteNumber) -head(ChoptankAvailableData) -@ - -There is an additional argument to the getDataAvailability called longNames, which defaults to FALSE. Setting longNames to TRUE will cause the function to make a web service call for each parameter and return expanded information on that parameter. Currently, this is a very slow process because each parameter code makes a unique web service call. If the site does not have many measured parameters, setting longNames to TRUE is reasonable. - -It is also possible to only request parameter information for a subset of variables. In the following example, we retrieve just the daily mean parameter information from the Choptank data availability dataframe (excluding all unit value and water quality values). getMultipleParameterNames is the function that is embedded in the getDataAvailability, but here can be used as a standalone function. - - -<<label=getSiteExtended, echo=TRUE>>= -# Continuing from the previous example: -# This pulls out just the daily data: -ChoptankDailyData <- subset(ChoptankAvailableData,"dv" == service) - -# This pulls out the mean: -ChoptankDailyData <- subset(ChoptankDailyData,"00003" == statCd) - -#Now, make a call to get all of the parameter information: -pCodeINFO <- getMultipleParameterNames(ChoptankDailyData$parameter_cd) - -#Merge the available dataframe with the parameter information dataframe: -ChoptankDailyData <- merge(ChoptankDailyData,pCodeINFO,by="parameter_cd") -@ - -The daily data at the Choptank River site can be displayed in a \LaTeX table using the xtable package. See Appendix \ref{app:createWordTable} for instructions on converting an R dataframe to a table in Microsoft Excel or Word. - -<<label=tablegda, echo=TRUE,results=tex>>= -tableData <- with(ChoptankDailyData, - data.frame(shortName=srsname, - Start=as.character(startDate), - End=as.character(endDate), - Count=as.character(count), - Units=parameter_units) - ) - - -data.table <- xtable(tableData,label="tab:gda", - caption="Daily mean data availabile at the Choptank River") -print(data.table, - caption.placement="top",include.rownames=FALSE) -@ - - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Parameter Information} -\label{sec:usgsParams} -%------------------------------------------------------------ -To obtain all of the available information concerning a measured parameter, use the getParameterInfo function: -<<label=getSite, echo=TRUE>>= -# Using defaults: -parameterCd <- "00618" -parameterINFO <- getParameterInfo(parameterCd) -colnames(parameterINFO) -@ - -Pulling out a specific example piece of information, in this case parameter name can be done as follows: -<<siteNames, echo=TRUE>>= -parameterINFO$parameter_nm -@ -Parameter information is obtained from \url{http://nwis.waterdata.usgs.gov/nwis/pmcodes/} -\FloatBarrier -%------------------------------------------------------------ -\subsection{Daily Values} -\label{sec:usgsDaily} -%------------------------------------------------------------ -To obtain historic daily records of USGS data, use the retrieveNWISData function. The arguments for this function are siteNumber, parameterCd, startDate, endDate, statCd, and a logical (true/false) interactive. There are 2 default argument: statCd (defaults to \texttt{"}00003\texttt{"}), and interactive (defaults to TRUE). If you want to use the default values, you do not need to list them in the function call. Setting the \texttt{"}interactive\texttt{"} option to true will walk you through the function. It might make more sense to run large batch collections with the interactive option set to FALSE. - -The dates (start and end) need to be in the format \texttt{"}YYYY-MM-DD\texttt{"} (note: the user does need to include the quotes). Setting the start date to \texttt{"}\texttt{"} will indicate to the program to ask for the earliest date, setting the end date to \texttt{"}\texttt{"} will ask for the latest available date. - -<<label=getNWISDaily, echo=TRUE, eval=FALSE>>= - -# Continuing with our Choptank River example -parameterCd <- "00060" # Discharge (cfs) -startDate <- "" # Will request earliest date -endDate <- "" # Will request latest date - -discharge <- retrieveNWISData(siteNumber, parameterCd, startDate, endDate) -@ - -The variable datetime is automatically imported as a Date. Each requested parameter has a value and remark code column. The names of these columns depend on the requested parameter and stat code combinations. USGS remark codes are often \texttt{"}A\texttt{"} (approved for publication) or \texttt{"}P\texttt{"} (provisional data subject to revision). A more complete list of remark codes can be found here: -\url{http://waterdata.usgs.gov/usa/nwis/help?codes_help} - -Another example that doesn't use the defaults would be a request for mean and maximum daily temperature and discharge in early 2012: -<<label=getNWIStemperature, echo=TRUE>>= - -parameterCd <- c("00010","00060") # Temperature and discharge -statCd <- c("00001","00003") # Mean and maximum -startDate <- "2012-01-01" -endDate <- "2012-06-30" - -temperatureAndFlow <- retrieveNWISData(siteNumber, parameterCd, - startDate, endDate, StatCd=statCd,interactive=FALSE) - -@ - -Daily data is pulled from \url{http://waterservices.usgs.gov/rest/DV-Test-Tool.html}. - -An example of plotting the above data (Figure \ref{fig:TD}): - -<<label=getNWIStemperaturePlot, echo=TRUE>>= -colnames <- names(temperatureAndFlow) -with(temperatureAndFlow, plot( - get(colnames[3]), get(colnames[6]), - xlab="Date",ylab="Temperature [C]" - )) -par(new=TRUE) -with(temperatureAndFlow, plot( - get(colnames[3]), get(colnames[8]), - col="red",type="l",xaxt="n",yaxt="n",xlab="",ylab="",axes=FALSE - )) -axis(4,col="red",col.axis="red") -mtext("Discharge [cfs]",side=4,line=3,col="red") -title(paste(ChoptankInfo$station.nm,"2012",sep=" ")) -@ - - -\begin{figure} -\begin{center} -<<label=fig1, fig=TRUE,echo=FALSE,width=6,height=4>>= -<<getNWIStemperaturePlot>> -@ -\end{center} -\caption{Temperature and discharge plot of Choptank River in 2012.} -\label{fig:TD} -\end{figure} - - -There are occasions where NWIS values are not reported as numbers, instead there might be text describing a certain event such as \texttt{"}Ice\texttt{"}. Any value that cannot be converted to a number will be reported as NA in this package. - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Unit Values} -\label{sec:usgsRT} -%------------------------------------------------------------ -Any data that are collected at regular time intervals (such as 15-minute or hourly) are known as \texttt{"}Unit Values\texttt{"} - many of these are delivered on a real time basis and very recent data (even less than an hour old in many cases) are available through the function retrieveUnitNWISData. Some of these Unit Values are available for the past several years, and some are only available for a recent time period such as 120 days or a year. Here is an example of a retrieval of such data. - -<<label=getNWISUnit, echo=TRUE>>= - -parameterCd <- "00060" # Discharge (cfs) -startDate <- "2012-05-12" -# or use (yesterday): startDate <- as.character(Sys.Date()-1) -endDate <- "2012-05-13" -# or use (today): endDate <- as.character(Sys.Date()) -dischargeToday <- retrieveUnitNWISData(siteNumber, parameterCd, - startDate, endDate) -@ -Which produces the following dataframe: -<<dischargeData, echo=FALSE>>= -head(dischargeToday) -@ - -Note that time now becomes important, so the variable datetime is a POSIXct, and the time zone is included in a separate column. Data is pulled from \url{http://waterservices.usgs.gov/rest/IV-Test-Tool.html}. There are occasions where NWIS values are not reported as numbers, instead a common example is \texttt{"}Ice\texttt{"}. Any value that cannot be converted to a number will be reported as NA in this package. - -A simple plotting example is shown in Figure \ref{fig:RT}: -<<label=getNWISUnit, echo=TRUE>>= -colnames <- names(dischargeToday) -with(dischargeToday, plot( - get(colnames[3]), get(colnames[4]), - ylab="Discharge [cfs]",xlab="" - )) -title(ChoptankInfo$station.nm) - -@ -\newpage - -\begin{figure} -\begin{center} -<<label=fig2, fig=TRUE,echo=FALSE,width=6,height=4>>= -<<getNWISUnit>> -@ -\end{center} -\caption{Real-time discharge plot of Choptank River from May 12-13, 2012.} -\label{fig:RT} -\end{figure} - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Water Quality Values} -\label{sec:usgsWQP} -%------------------------------------------------------------ -To get USGS water quality data from water samples collected at the streamgage (as distinct from unit values collected through some type of automatic monitor) we can use the Water Quality Data Portal: \url{http://www.waterqualitydata.us/}. The raw data are obtained from the function getRawQWData, with the similar input arguments: siteNumber, parameterCd, startDate, endDate, and interactive. The difference is in parameterCd, in this function multiple parameters can be queried using a \texttt{"};\texttt{"} separator, and setting parameterCd to \texttt{"}\texttt{"} will return all of the measured observations. The raw data can be overwelming (see Appendix \ref{sec:appendix2WQP}), a simplified version of the data can be obtained using getQWData.There is a large amount of data returned for each observation. - - -<<label=getQW, echo=TRUE>>= - -# Dissolved Nitrate parameter codes: -parameterCd <- c("00618","71851") -startDate <- "1979-10-11" -endDate <- "2012-12-18" - -dissolvedNitrate <- getRawQWData(siteNumber, parameterCd, - startDate, endDate) - -dissolvedNitrateSimple <- getQWData(siteNumber, parameterCd, - startDate, endDate) -names(dissolvedNitrateSimple) -@ -Note that in this dataframe, datetime is imported as Dates (no times are included), and the qualifier is either blank or \texttt{"}\verb@<@\texttt{"} signifying a censored value. A plotting example is shown in Figure \ref{fig:nitrate}. - -<<label=getQWtemperaturePlot, echo=TRUE>>= -with(dissolvedNitrateSimple, plot( - dateTime, value.00618, - xlab="Date",ylab = paste(parameterINFO$srsname, - "[",parameterINFO$parameter_units,"]") - )) -title(ChoptankInfo$station.nm) -@ - -\begin{figure} -\begin{center} -<<label=fig3, fig=TRUE,echo=FALSE,width=6,height=4>>= -<<getQWtemperaturePlot>> -@ -\end{center} -\caption{Nitrate plot of Choptank River.} -\label{fig:nitrate} -\end{figure} - -\FloatBarrier -%------------------------------------------------------------ -\subsection{STORET Water Quality Retrievals} -\label{sec:usgsSTORET} -%------------------------------------------------------------ -There are additional data sets available on the Water Quality Data Portal (\url{http://www.waterqualitydata.us/}). These data sets can be housed in either the STORET (data from EPA) or NWIS database. Since STORET does not use USGS parameter codes, a \texttt{"}characteristic name\texttt{"} must be supplied. The following example retrieves specific conductance from a DNR site in Wisconsin. - -<<label=getQWData, echo=TRUE>>= -specificCond <- getWQPData('WIDNR_WQX-10032762', - 'Specific conductance', '', '') -head(specificCond) -@ - -\FloatBarrier -%------------------------------------------------------------ -\subsection{URL Construction} -\label{sec:usgsURL} -%------------------------------------------------------------ -There may be times when you might be interested in seeing the URL (web address) that was used to obtain the raw data. The constructNWISURL function returns the URL. Aside from input variables that have already been described, there is a new argument \texttt{"}service\texttt{"}. The service argument can be \texttt{"}dv\texttt{"} (daily values), \texttt{"}uv\texttt{"} (unit values), \texttt{"}qw\texttt{"} (NWIS water quality values), or \texttt{"}wqp\texttt{"} (general Water Quality Portal values). - - -<<label=geturl, echo=TRUE, eval=FALSE>>= -# Dissolved Nitrate parameter codes: -pCode <- c("00618","71851") -startDate <- "1964-06-11" -endDate <- "2012-12-18" -url_qw <- constructNWISURL(siteNumber,pCode,startDate,endDate,'qw') -url_dv <- constructNWISURL(siteNumber,"00060",startDate,endDate,'dv',statCd="00003") -url_uv <- constructNWISURL(siteNumber,"00060",startDate,endDate,'uv') -@ - -\FloatBarrier -%------------------------------------------------------------ -\section{Data Retrievals Structured For Use In The EGRET Package} -%------------------------------------------------------------ -Rather than using the raw data as retrieved by the web, the dataRetrieval package also includes functions that return the data in a structure that has been designed to work with the EGRET R package (\url{https://github.com/USGS-R/EGRET/wiki}). In general, these dataframes may be much more 'R-friendly' than the raw data, and will contain additional date information that allows for efficient data analysis. - -In this section, we use 3 dataRetrieval functions to get sufficient data to perform an EGRET analysis. We will continue analyzing the Choptank River. We will be retrieving essentially the same data that were retrieved in the previous section, but in this case it will be structured into three EGRET-specific dataframes. The daily discharge data will be placed in a dataframe called Daily. The nitrate sample data will be placed in a dataframe called Sample. The data about the site and the parameter will be placed in a dataframe called INFO. Although these dataframes were designed to work with the EGRET R package, they can be very useful for a wide range of hydrologic studies that don't use EGRET. - -%------------------------------------------------------------ -\subsection{INFO Data} -%------------------------------------------------------------ -The function to obtain metadata, or data about the streamgage and measured parameters is getMetaData. This function combines getSiteFileData and getParameterInfo, producing one dataframe called INFO. - -<<ThirdExample>>= -parameterCd <- "00618" -INFO <-getMetaData(siteNumber,parameterCd, interactive=FALSE) -@ - -Column names in the INFO dataframe are listed in Appendix 2 (\ref{sec:appendix2INFO}). - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Daily Data} -%------------------------------------------------------------ -The function to obtain the daily values (discharge in this case) is getDVData. It requires the inputs siteNumber, ParameterCd, StartDate, EndDate, interactive, and convert. Most of these arguments are described in the previous section, however \texttt{"}convert\texttt{"} is a new argument (defaults to TRUE), and it tells the program to convert the values from cubic feet per second (cfs) to cubic meters per second (cms). For EGRET applications with NWIS web retrieval, do not use this argument (the default is TRUE), EGRET assumes that discharge is always in cubic meters per second. If you don't want this conversion and are not using EGRET, set convert=FALSE in the function call. - -<<firstExample>>= -siteNumber <- "01491000" -startDate <- "2000-01-01" -endDate <- "2013-01-01" -# This call will get NWIS data that is in cfs, and convert it -# to cms since we didn't override the default in the convert argument: -Daily <- getDVData(siteNumber, "00060", startDate, endDate,interactive=FALSE) -@ - -Details of the Daily dataframe are listed below: - -<<label=colNamesDaily, echo=FALSE,results=tex>>= -ColumnName <- c("Date", "Q", "Julian","Month","Day","DecYear","MonthSeq","Qualifier","i","LogQ","Q7","Q30") -Type <- c("Date", "number", "number","integer","integer","number","integer","string","integer","number","number","number") -Description <- c("Date", "Discharge", "Number of days since January 1, 1850", "Month of the year [1-12]", "Day of the year [1-366]", "Decimal year", "Number of months since January 1, 1850", "Qualifing code", "Index of days from the start of the data frame", "Natural logarithm of Q", "7 day running average of Q", "30 running average of Q") -Units <- c("date", "cms","days", "months","days","years","months", "character","days","numeric","cms","cms") - -DF <- data.frame(ColumnName,Type,Description,Units) - -data.table <- xtable(DF, - caption="Daily dataframe") -print(data.table, caption.placement="top",floating="FALSE",latex.environments=NULL,include.rownames=FALSE) -@ -\\* - -If there are discharge values of zero, the code will add a small constant to all of the daily discharges. This constant is 0.001 times the mean discharge. The code will also report on the number of zero values and the size of the constant. EGRET should only be used if the number of zero values is a very small fraction of the total days in the record (say less than 0.1\% of the days). Columns Q7 and Q30 are the 7 and 30 day running averages for the 7 or 30 days ending on this specific date. - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Sample Data} -%------------------------------------------------------------ -The function to obtain sample data from the water quality portal is getSampleData. The arguments for this function are also siteNumber, ParameterCd, StartDate, EndDate, interactive. These are the same inputs as getRawQWData or getQWData as described in the previous section. - -<<secondExample>>= -Sample <-getSampleData(siteNumber,parameterCd, - startDate, endDate,interactive=FALSE) -@ - -Details of the Sample dataframe are listed below: - -<<label=colNamesQW, echo=FALSE,results=tex>>= -ColumnName <- c("Date", "ConcLow", "ConcHigh", "Uncen", "ConcAve", "Julian","Month","Day","DecYear","MonthSeq","SinDY","CosDY","Q footnote","LogQ footnote") -Type <- c("Date", "number","number","integer","number", "number","integer","integer","number","integer","number","number","number","number") -Description <- c("Date", "Lower limit of concentration", "Upper limit of concentration", "Uncensored data (1=true, 0=false)", "Average of ConcLow and ConcHigh","Number of days since January 1, 1850", "Month of the year [1-12]", "Day of the year [1-366]", "Decimal year", "Number of months since January 1, 1850", "Sine of DecYear", "Cosine of DecYear", "Discharge", "Natural logarithm of flow") -Units <- c("date","mg/L","mg/L","integer","mg/L","days","months","days","years","months","numeric","numeric","cms", "numeric") - -DF <- data.frame(ColumnName,Type,Description,Units) - -data.table <- xtable(DF, - caption="Sample dataframe") -print(data.table, caption.placement="top",include.rownames=FALSE,table.placement="!ht", - sanitize.text.function=function(str)gsub("footnote","\\footnotemark[1]",str,fixed=TRUE)) -@ -\footnotetext[1]{Flow columns are populated from data in the Daily dataframe after calling the mergeReport function.} - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Censored Values: Summation Explanation} -%------------------------------------------------------------ -In the typical case where none of the data are censored (that is, no values are reported as \texttt{"}less-than\texttt{"} values) the ConcLow = ConcHigh = ConcAve all of which are equal to the reported value and Uncen=0. In the typical form of censoring where a value is reported as less than the reporting limit, then ConcLow = NA, ConcHigh = reporting limit, ConcAve = 0.5 * reporting limit, and Uncen = 1. - -As an example to understand how the dataRetrieval package handles a more complex censoring problem, let us say that in 2004 and earlier, we computed a total phosphorus (tp) as the sum of dissolved phosphorus (dp) and particulate phosphorus (pp). From 2005 and onward, we have direct measurements of total phosphorus (tp). A small subset of this fictional data looks like this: - -\begin{center} - -<<label=exampleComplexQW, echo=FALSE,results=tex>>= -cdate <- c("2003-02-15","2003-06-30","2004-09-15","2005-01-30","2005-05-30","2005-10-30") -rdp <- c("", "<","<","","","") -dp <- c(0.02,0.01,0.005,NA,NA,NA) -rpp <- c("", "","<","","","") -pp <- c(0.5,0.3,0.2,NA,NA,NA) -rtp <- c("","","","","<","<") -tp <- c(NA,NA,NA,0.43,0.05,0.02) - -DF <- data.frame(cdate,rdp,dp,rpp,pp,rtp,tp) - -data.table <- xtable(DF, - caption="Example data") -print(data.table, caption.placement="top",floating="FALSE",latex.environments=NULL,include.rownames=FALSE) -@ - -\end{center} - - -The dataRetrieval package will \texttt{"}add up\texttt{"} all the values in a given row to form the total for that sample. Thus, you only want to enter data that should be added together. For example, we might know the value for dp on 5/30/2005, but we don't want to put it in the table because under the rules of this data set, we are not suppose to add it in to the values in 2005. - -For every sample, the EGRET package requires a pair of numbers to define an interval in which the true value lies (ConcLow and ConcHigh). In a simple non-censored case (the reported value is above the detection limit), ConcLow equals ConcHigh and the interval collapses down to a single point.In a simple censored case, the value might be reported as <0.2, then ConcLow=NA and ConcHigh=0.2. We use NA instead of 0 as a way to elegantly handle future logarithm calculations. - -For the more complex example case, let us say dp is reported as <0.01 and pp is reported as 0.3. We know that the total must be at least 0.3 and could be as much as 0.31. Therefore, ConcLow=0.3 and ConcHigh=0.31. Another case would be if dp is reported as <0.005 and pp is reported <0.2. We know in this case that the true value could be as low as zero, but could be as high as 0.205. Therefore, in this case, ConcLow=NA and ConcHigh=0.205. The Sample dataframe for the example data is therefore: - -<<thirdExample,echo=FALSE>>= -getPreLoadedSampleData(DF) - -@ - -\FloatBarrier -%------------------------------------------------------------ -\subsection{User-Generated Data Files} -%------------------------------------------------------------ -Aside from retrieving data from the USGS web services, the dataRetrieval package includes functions to generate the Daily and Sample data frame from local files. - -%------------------------------------------------------------ -\subsubsection{getDailyDataFromFile} -%------------------------------------------------------------ -getDailyDataFromFile will load a user-supplied text file and convert it to the Daily dataframe. The file should have two columns, the first dates, the second values. The dates should be formatted either mm/dd/yyyy or yyyy-mm-dd. Using a 4-digit year is required. This function has the following inputs: filePath, fileName,hasHeader (TRUE/FALSE), separator, qUnit, and interactive (TRUE/FALSE). filePath is a string that defines the path to your file. This can either be a full path, or path relative to your R working directory. The input fileName is a string that defines the file name (including the extension). - -Text files that contain this sort of data require some sort of a separator, for example, a 'csv' file (comma-separated value) file uses a comma to separate the date and value column. A tab delimited file would use a tab (\texttt{"}\verb@\t@\texttt{"}) rather than the comma (\texttt{"},\texttt{"}). The type of separator you use can be defined in the function call in the \texttt{"}separator\texttt{"} argument, the default is \texttt{"},\texttt{\texttt{"}}. Another function input is a logical variable: hasHeader. The default is TRUE. If your data does not have column names, set this variable to FALSE. - -Finally, qUnit is a numeric argument that defines the discharge units used in the input file. The default is qUnit = 1 which assumes discharge is in cubic feet per second. If the discharge in the file is already in cubic meters per second then set qUnit = 2. If it is in some other units (like liters per second or acre-feet per day), the user will have to pre-process the data with a unit conversion that changes it to either cubic feet per second or cubic meters per second. - -So, if you have a file called \texttt{"}ChoptankRiverFlow.txt\texttt{"} located in a folder called \texttt{"}RData\texttt{"} on the C drive (this is a Window's example), and the file is structured as follows (tab-separated): -\begin{verbatim} -date Qdaily -10/1/1999 107 -10/2/1999 85 -10/3/1999 76 -10/4/1999 76 -10/5/1999 113 -10/6/1999 98 -... -\end{verbatim} - -The call to open this file, convert the flow to cubic meters per second, and populate the Daily data frame would be: -<<openDaily, eval = FALSE>>= -fileName <- "ChoptankRiverFlow.txt" -filePath <- "C:/RData/" -Daily <- getDailyDataFromFile(filePath,fileName,separator="\t",interactive=FALSE) -@ - -\FloatBarrier -%------------------------------------------------------------ -\subsubsection{getSampleDataFromFile} -%------------------------------------------------------------ -Similarly to the previous section, getSampleDataFromFile will import a user-generated file and populate the Sample dataframe. The difference between sample data and flow data is that the code requires a third column that contains a remark code, either blank or \texttt{"}\verb@<@\texttt{"}, which will tell the program that the data was 'left-censored' (or, below the detection limit of the sensor). Therefore, the data is required to be in the form: date, remark, value. If multiple constituents are going to be used, the format can be date, remark\_A, value\_A, remark\_b, value\_b, etc... An example of a comma-delimited file would be: - -\begin{verbatim} -cdate;remarkCode;Nitrate -10/7/1999,,1.4 -11/4/1999,<,0.99 -12/3/1999,,1.42 -1/4/2000,,1.59 -2/3/2000,,1.54 -... -\end{verbatim} -The call to open this file, and populate the Sample dataframe would be: -<<openSample, eval = FALSE>>= -fileName <- "ChoptankRiverNitrate.csv" -filePath <- "C:/RData/" -Sample <- getSampleDataFromFile(filePath,fileName,separator=",",interactive=FALSE) -@ - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Merge Report} -%------------------------------------------------------------ -Finally, there is a function called mergeReport that will look at both the Daily and Sample dataframe, and populate Q and LogQ columns into the Sample dataframe. The default arguments are Daily and Sample, however if you want to use other similarly structured dataframes, you can specify localDaily or localSample. Once mergeReport has been run, the Sample dataframe will be augumented with the daily discharges for all the days with samples. None of the water quality functions in EGRET will work without first having run the mergeReport function. - - -<<mergeExample>>= -siteNumber <- "01491000" -parameterCd <- "00631" # Nitrate -startDate <- "2000-01-01" -endDate <- "2013-01-01" - -Daily <- getDVData(siteNumber, "00060", startDate, endDate,interactive=FALSE) -Sample <- getSampleData(siteNumber,parameterCd, startDate, endDate, interactive=FALSE) -Sample <- mergeReport() -head(Sample) -@ - -\FloatBarrier -%------------------------------------------------------------ -\subsection{EGRET Plots} -%------------------------------------------------------------ -As has been mentioned, the data is specifically formatted to be used with the EGRET package. The EGRET package has powerful modeling capabilities using WRTDS, but also has a variety of graphing and tablular tools to explore the data without using the WRTDS algorithm. See the EGRET vignette, user guide, and/or wiki (\url{https://github.com/USGS-R/EGRET/wiki}) for detailed information. The following figure is an example of one of the plotting functions that can be used directly from the dataRetrieval dataframes. - -<<egretEx, echo=TRUE, eval=TRUE>>= -# Continuing Choptank example from the previous sections -library(EGRET) -multiPlotDataOverview() -@ - -\begin{figure}[ht] -\begin{center} - -<<label=figegretEx, fig=TRUE,echo=FALSE>>= -<<egretEx>> -@ -\end{center} -\caption{Default multiPlotDataOverview} -\label{fig:multiPlotDataOverview} -\end{figure} - -\clearpage -\appendix -%------------------------------------------------------------ -\section{Getting Started in R} -\label{sec:appendix1} -%------------------------------------------------------------ -This section describes the options for downloading and installing the dataRetrieval package. - -%------------------------------------------------------------ -\subsection{New to R?} -%------------------------------------------------------------ -If you are new to R, you will need to first install the latest version of R, which can be found here: \url{http://www.r-project.org/}. - -There are many options for running and editing R code, one nice environment to learn R is RStudio. RStudio can be downloaded here: \url{http://rstudio.org/}. Once R and RStudio are installed, the dataRetrieval package needs to be installed as described in the next section. - -At any time, you can get information about any function in R by typing a question mark before the functions name. This will open a file (in RStudio, in the Help window) that describes the function, the required arguments, and provides working examples. - -<<helpFunc,eval = FALSE>>= -?removeDuplicates -@ - -To see the raw code for a particular code, type the name of the function: -<<rawFunc,eval = TRUE>>= -removeDuplicates -@ - - -%------------------------------------------------------------ -\subsection{R User: Installing dataRetrieval} -%------------------------------------------------------------ -Before installing dataRetrieval, the zoo packages must be installed from CRAN: - -<<installFromCran,eval = FALSE>>= -install.packages("zoo") -install.packages("dataRetrieval", repos="http://usgs-r.github.com", type="source") -@ - -It is a good idea to re-start the R enviornment after installing the package, especially if installing an updated version. Some users have found it necessary to delete the previous version's package folder before installing newer version of dataRetrieval. If you are experiencing issues after updating a package, trying deleting the package folder - the default location for Windows is something like this: C:/Users/userA/Documents/R/win-library/2.15/dataRetrieval, and the default for a Mac: /Users/userA/Library/R/2.15/library/dataRetrieval. Then, re-install the package using the directions above. Moving to CRAN should solve this problem. - -After installing the package, you need to open the library each time you re-start R. This is done with the simple command: -<<openLibraryTest, eval=FALSE>>= -library(dataRetrieval) -@ -Using RStudio, you could alternatively click on the checkbox for dataRetrieval in the Packages window. - -%------------------------------------------------------------ -\subsection{R Developers: Installing dataRetrieval from gitHub} -%------------------------------------------------------------ -Alternatively, R-developers can install the latest working version of dataRetrieval directly from gitHub using the devtools package (available on CRAN). Rtools (for Windows) and appropriate \LaTeX\ tools are required. Be aware that the version installed using this method isn't necessarily the same as the version in the stable release branch. - - -<<gitInstal,eval = FALSE>>= -library(devtools) -install_github("dataRetrieval", "USGS-R") -@ -To then open the library, simply type: - -<<openLibrary, eval=FALSE>>= -library(dataRetrieval) -@ - -%------------------------------------------------------------ -\section{Columns Names} -\label{sec:appendix2} -%------------------------------------------------------------ - -%------------------------------------------------------------ -\subsection{INFO dataframe} -\label{sec:appendix2INFO} -%------------------------------------------------------------ - -<<label=colNamesQW, echo=FALSE,results=tex>>= -infoDF <- data.frame(ColumnNames=names(INFO)) -data.table <- xtable(infoDF, - caption="Column names in the INFO dataframe") -print(data.table, caption.placement="top",floating="FALSE",latex.environments=NULL,include.rownames=FALSE,include.colnames=FALSE) -@ - -\FloatBarrier - -%------------------------------------------------------------ -\subsection{Water Quality Portal} -\label{sec:appendix2WQP} -%------------------------------------------------------------ - -There are 62 columns returned from the water quality portal. - -<<label=colNamesQW, echo=FALSE,results=tex>>= -infoDF <- data.frame(ColumnNames=names(dissolvedNitrate[1:40])) -data.table <- xtable(infoDF, - caption="Column names in dissolvedNitrate") -print(data.table, caption.placement="top",floating="FALSE",latex.environments=NULL, - include.rownames=FALSE,include.colnames=FALSE) -@ - -\FloatBarrier - -<<label=colNamesQW2, echo=FALSE,results=tex>>= -infoDF <- data.frame(ColumnNames_Continued=names(dissolvedNitrate[41:62])) -data.table <- xtable(infoDF, - caption="Column names in dissolvedNitrate") -print(data.table, caption.placement="top",floating="FALSE",latex.environments=NULL, - include.rownames=FALSE,include.colnames=FALSE) -@ - -\clearpage - -%------------------------------------------------------------ -\section{Creating tables in Microsoft from R} -\label{app:createWordTable} -%------------------------------------------------------------ -There are a few steps that are required in order to create a table in a Microsoft product (Excel, Word, Powerpoint, etc.) from an R dataframe. There are certainly a variety of good methods, one of which is detailed here. The example we will step through here will be to create a table in Microsoft Word based on the dataframe tableData: - -<<label=getSiteApp, echo=TRUE>>= -ChoptankAvailableData <- getDataAvailability(siteNumber) -ChoptankDailyData <- ChoptankAvailableData["dv" == ChoptankAvailableData$service,] -ChoptankDailyData <- ChoptankDailyData["00003" == ChoptankDailyData$statCd,] -pCodeINFO <- getMultipleParameterNames(ChoptankDailyData$parameter_cd, interactive=FALSE) -ChoptankDailyData <- merge(ChoptankDailyData,pCodeINFO,by="parameter_cd") - -tableData <- with(ChoptankDailyData, - data.frame( - shortName=srsname, - Start=startDate, - End=endDate, - Count=count, - Units=parameter_units) - ) -@ - -First, save the dataframe as a tab delimited file (you don't want to use comma delimited because there are commas in some of the data elements): - - -<<label=saveData, echo=TRUE, eval=FALSE>>= -write.table(tableData, file="tableData.tsv",sep="\t", - row.names = FALSE,quote=FALSE) -@ - -This will save a file in your working directory called tableData.tsv. You can see your working directory by typing getwd() in the R console. Opening the file in a general-purpose text editor, you should see the following: - -\begin{verbatim} -shortName Start End Count Units -Temperature, water 2010-10-01 2012-06-24 575 deg C -Stream flow, mean. daily 1948-01-01 2013-03-13 23814 cfs -Specific conductance 2010-10-01 2012-06-24 551 uS/cm @25C -Suspended sediment concentration (SSC) 1980-10-01 1991-09-30 3651 mg/l -Suspended sediment discharge 1980-10-01 1991-09-30 3652 tons/day -\end{verbatim} - -To open this file in Excel: -\begin{enumerate} -\item Open Excel -\item Click on the File tab -\item Click on the Open option -\item Browse to the working directory (as shown in the results of getwd()) -\item Next to the File name text box, change the dropdown type to All Files (*.*) -\item Double click tableData.tsv -\item A text import wizard will open up, in the first window, choose the Delimited radio button if it is not automatically picked, then click on Next. -\item In the second window, click on the Tab delimiter if it is not automatically checked, then click Finished. -\item Use the many formatting tools within Excel to customize the table -\end{enumerate} - -From Excel, it is simple to copy and paste the tables in other Microsoft products. An example using one of the default Excel table formats is here. - -\begin{figure}[ht!] -\centering - \resizebox{0.9\textwidth}{!}{\includegraphics{table1.png}} -\caption{A simple table produced in Microsoft Excel} -\label{overflow} -\end{figure} - -\clearpage -%------------------------------------------------------------ -% BIBLIO -%------------------------------------------------------------ -\begin{thebibliography}{10} - -\bibitem{HirschI} -Helsel, D.R. and R. M. Hirsch, 2002. Statistical Methods in Water Resources Techniques of Water Resources Investigations, Book 4, chapter A3. U.S. Geological Survey. 522 pages. \url{http://pubs.usgs.gov/twri/twri4a3/} - -\bibitem{HirschII} -Hirsch, R. M., Moyer, D. L. and Archfield, S. A. (2010), Weighted Regressions on Time, Discharge, and Season (WRTDS), with an Application to Chesapeake Bay River Inputs. JAWRA Journal of the American Water Resources Association, 46: 857-880. doi: 10.1111/j.1752-1688.2010.00482.x \url{http://onlinelibrary.wiley.com/doi/10.1111/j.1752-1688.2010.00482.x/full} - -\bibitem{HirschIII} -Sprague, L. A., Hirsch, R. M., and Aulenbach, B. T. (2011), Nitrate in the Mississippi River and Its Tributaries, 1980 to 2008: Are We Making Progress? Environmental Science \& Technology, 45 (17): 7209-7216. doi: 10.1021/es201221s \url{http://pubs.acs.org/doi/abs/10.1021/es201221s} - -\end{thebibliography} - -\end{document} - -\end{document} diff --git a/inst/doc/dataRetrieval.log b/inst/doc/dataRetrieval.log deleted file mode 100644 index 47a14b733eb32ac66e8d0da13c449f588fb156b7..0000000000000000000000000000000000000000 --- a/inst/doc/dataRetrieval.log +++ /dev/null @@ -1,699 +0,0 @@ -This is pdfTeX, Version 3.1415926-2.3-1.40.12 (MiKTeX 2.9) (preloaded format=pdflatex 2012.1.6) 8 APR 2013 10:10 -entering extended mode -**dataRetrieval.tex -(D:\LADData\RCode\dataRetrieval\inst\doc\dataRetrieval.tex -LaTeX2e <2011/06/27> -Babel <v3.8m> and hyphenation patterns for english, afrikaans, ancientgreek, ar -abic, armenian, assamese, basque, bengali, bokmal, bulgarian, catalan, coptic, -croatian, czech, danish, dutch, esperanto, estonian, farsi, finnish, french, ga -lician, german, german-x-2009-06-19, greek, gujarati, hindi, hungarian, iceland -ic, indonesian, interlingua, irish, italian, kannada, kurmanji, lao, latin, lat -vian, lithuanian, malayalam, marathi, mongolian, mongolianlmc, monogreek, ngerm -an, ngerman-x-2009-06-19, nynorsk, oriya, panjabi, pinyin, polish, portuguese, -romanian, russian, sanskrit, serbian, slovak, slovenian, spanish, swedish, swis -sgerman, tamil, telugu, turkish, turkmen, ukenglish, ukrainian, uppersorbian, u -senglishmax, welsh, loaded. -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\article.cls" -Document Class: article 2007/10/19 v1.4h Standard LaTeX document class -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\size11.clo" -File: size11.clo 2007/10/19 v1.4h Standard LaTeX file (size option) -) -\c@part=\count79 -\c@section=\count80 -\c@subsection=\count81 -\c@subsubsection=\count82 -\c@paragraph=\count83 -\c@subparagraph=\count84 -\c@figure=\count85 -\c@table=\count86 -\abovecaptionskip=\skip41 -\belowcaptionskip=\skip42 -\bibindent=\dimen102 -) -(C:\Users\ldecicco\AppData\Roaming\MiKTeX\2.9\tex\latex\amsmath\amsmath.sty -Package: amsmath 2013/01/14 v2.14 AMS math features -\@mathmargin=\skip43 - -For additional information on amsmath, use the `?' option. -(C:\Users\ldecicco\AppData\Roaming\MiKTeX\2.9\tex\latex\amsmath\amstext.sty -Package: amstext 2000/06/29 v2.01 - -(C:\Users\ldecicco\AppData\Roaming\MiKTeX\2.9\tex\latex\amsmath\amsgen.sty -File: amsgen.sty 1999/11/30 v2.0 -\@emptytoks=\toks14 -\ex@=\dimen103 -)) -(C:\Users\ldecicco\AppData\Roaming\MiKTeX\2.9\tex\latex\amsmath\amsbsy.sty -Package: amsbsy 1999/11/29 v1.2d -\pmbraise@=\dimen104 -) -(C:\Users\ldecicco\AppData\Roaming\MiKTeX\2.9\tex\latex\amsmath\amsopn.sty -Package: amsopn 1999/12/14 v2.01 operator names -) -\inf@bad=\count87 -LaTeX Info: Redefining \frac on input line 210. -\uproot@=\count88 -\leftroot@=\count89 -LaTeX Info: Redefining \overline on input line 306. -\classnum@=\count90 -\DOTSCASE@=\count91 -LaTeX Info: Redefining \ldots on input line 378. -LaTeX Info: Redefining \dots on input line 381. -LaTeX Info: Redefining \cdots on input line 466. -\Mathstrutbox@=\box26 -\strutbox@=\box27 -\big@size=\dimen105 -LaTeX Font Info: Redeclaring font encoding OML on input line 566. -LaTeX Font Info: Redeclaring font encoding OMS on input line 567. -\macc@depth=\count92 -\c@MaxMatrixCols=\count93 -\dotsspace@=\muskip10 -\c@parentequation=\count94 -\dspbrk@lvl=\count95 -\tag@help=\toks15 -\row@=\count96 -\column@=\count97 -\maxfields@=\count98 -\andhelp@=\toks16 -\eqnshift@=\dimen106 -\alignsep@=\dimen107 -\tagshift@=\dimen108 -\tagwidth@=\dimen109 -\totwidth@=\dimen110 -\lineht@=\dimen111 -\@envbody=\toks17 -\multlinegap=\skip44 -\multlinetaggap=\skip45 -\mathdisplay@stack=\toks18 -LaTeX Info: Redefining \[ on input line 2665. -LaTeX Info: Redefining \] on input line 2666. -) -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\psnfss\times.sty" -Package: times 2005/04/12 PSNFSS-v9.2a (SPQR) -) -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\hyperref\hyperref.sty" -Package: hyperref 2011/08/19 v6.82h Hypertext links for LaTeX - -("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\oberdiek\hobsub-hyperref.sty" -Package: hobsub-hyperref 2011/04/23 v1.4 Bundle oberdiek, subset hyperref (HO) - -("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\oberdiek\hobsub-generic.sty" -Package: hobsub-generic 2011/04/23 v1.4 Bundle oberdiek, subset generic (HO) -Package: hobsub 2011/04/23 v1.4 Subsetting bundle oberdiek (HO) -Package: infwarerr 2010/04/08 v1.3 Providing info/warning/message (HO) -Package: ltxcmds 2011/04/18 v1.20 LaTeX kernel commands for general use (HO) -Package: ifluatex 2010/03/01 v1.3 Provides the ifluatex switch (HO) -Package ifluatex Info: LuaTeX not detected. -Package: ifvtex 2010/03/01 v1.5 Switches for detecting VTeX and its modes (HO) -Package ifvtex Info: VTeX not detected. -Package: intcalc 2007/09/27 v1.1 Expandable integer calculations (HO) -Package: ifpdf 2011/01/30 v2.3 Provides the ifpdf switch (HO) -Package ifpdf Info: pdfTeX in PDF mode is detected. -Package: etexcmds 2011/02/16 v1.5 Prefix for e-TeX command names (HO) -Package etexcmds Info: Could not find \expanded. -(etexcmds) That can mean that you are not using pdfTeX 1.50 or -(etexcmds) that some package has redefined \expanded. -(etexcmds) In the latter case, load this package earlier. -Package: kvsetkeys 2011/04/07 v1.13 Key value parser (HO) -Package: kvdefinekeys 2011/04/07 v1.3 Defining keys (HO) -Package: pdftexcmds 2011/04/22 v0.16 Utilities of pdfTeX for LuaTeX (HO) -Package pdftexcmds Info: LuaTeX not detected. -Package pdftexcmds Info: \pdf@primitive is available. -Package pdftexcmds Info: \pdf@ifprimitive is available. -Package pdftexcmds Info: \pdfdraftmode found. -Package: pdfescape 2011/04/04 v1.12 Provides string conversions (HO) -Package: bigintcalc 2011/01/30 v1.2 Expandable big integer calculations (HO) -Package: bitset 2011/01/30 v1.1 Data type bit set (HO) -Package: uniquecounter 2011/01/30 v1.2 Provides unlimited unique counter (HO) -) -Package hobsub Info: Skipping package `hobsub' (already loaded). -Package: letltxmacro 2010/09/02 v1.4 Let assignment for LaTeX macros (HO) -Package: hopatch 2011/01/30 v1.0 Wrapper for package hooks (HO) -Package: xcolor-patch 2011/01/30 xcolor patch -Package: atveryend 2011/04/23 v1.7 Hooks at very end of document (HO) -Package: atbegshi 2011/01/30 v1.15 At begin shipout hook (HO) -Package: refcount 2010/12/01 v3.2 Data extraction from references (HO) -Package: hycolor 2011/01/30 v1.7 Color options of hyperref/bookmark (HO) -) -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\graphics\keyval.sty" -Package: keyval 1999/03/16 v1.13 key=value parser (DPC) -\KV@toks@=\toks19 -) -("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\ifxetex\ifxetex.sty" -Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional -) -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\oberdiek\kvoptions.sty" -Package: kvoptions 2010/12/23 v3.10 Keyval support for LaTeX options (HO) -) -\@linkdim=\dimen112 -\Hy@linkcounter=\count99 -\Hy@pagecounter=\count100 - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\hyperref\pd1enc.def" -File: pd1enc.def 2011/08/19 v6.82h Hyperref: PDFDocEncoding definition (HO) -) -\Hy@SavedSpaceFactor=\count101 - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\00miktex\hyperref.cfg" -File: hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive -) -Package hyperref Info: Hyper figures OFF on input line 4053. -Package hyperref Info: Link nesting OFF on input line 4058. -Package hyperref Info: Hyper index ON on input line 4061. -Package hyperref Info: Plain pages OFF on input line 4068. -Package hyperref Info: Backreferencing OFF on input line 4073. -Package hyperref Info: Implicit mode ON; LaTeX internals redefined. -Package hyperref Info: Bookmarks ON on input line 4291. -\c@Hy@tempcnt=\count102 - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\ltxmisc\url.sty" -\Urlmuskip=\muskip11 -Package: url 2006/04/12 ver 3.3 Verb mode for urls, etc. -) -LaTeX Info: Redefining \url on input line 4644. -\Fld@menulength=\count103 -\Field@Width=\dimen113 -\Fld@charsize=\dimen114 -Package hyperref Info: Hyper figures OFF on input line 5730. -Package hyperref Info: Link nesting OFF on input line 5735. -Package hyperref Info: Hyper index ON on input line 5738. -Package hyperref Info: backreferencing OFF on input line 5745. -Package hyperref Info: Link coloring OFF on input line 5750. -Package hyperref Info: Link coloring with OCG OFF on input line 5755. -Package hyperref Info: PDF/A mode OFF on input line 5760. -LaTeX Info: Redefining \ref on input line 5800. -LaTeX Info: Redefining \pageref on input line 5804. -\Hy@abspage=\count104 -\c@Item=\count105 -\c@Hfootnote=\count106 -) - -Package hyperref Message: Driver (autodetected): hpdftex. - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\hyperref\hpdftex.def" -File: hpdftex.def 2011/08/19 v6.82h Hyperref driver for pdfTeX -\Fld@listcount=\count107 -\c@bookmark@seq@number=\count108 - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\oberdiek\rerunfilecheck.sty" -Package: rerunfilecheck 2011/04/15 v1.7 Rerun checks for auxiliary files (HO) -Package uniquecounter Info: New unique counter `rerunfilecheck' on input line 2 -82. -) -\Hy@SectionHShift=\skip46 -) -(C:\Users\ldecicco\AppData\Roaming\MiKTeX\2.9\tex\latex\natbib\natbib.sty -Package: natbib 2010/09/13 8.31b (PWD, AO) -\bibhang=\skip47 -\bibsep=\skip48 -LaTeX Info: Redefining \cite on input line 694. -\c@NAT@ctr=\count109 -) -("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\babel\babel.sty" -Package: babel 2008/07/08 v3.8m The Babel package - -************************************* -* Local config file bblopts.cfg used -* -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\00miktex\bblopts.cfg" -File: bblopts.cfg 2006/07/31 v1.0 MiKTeX 'babel' configuration -) -("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\babel\english.ldf" -Language: english 2005/03/30 v3.3o English support from the babel system - -("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\babel\babel.def" -File: babel.def 2008/07/08 v3.8m Babel common definitions -\babel@savecnt=\count110 -\U@D=\dimen115 -) -\l@canadian = a dialect from \language\l@american -\l@australian = a dialect from \language\l@british -\l@newzealand = a dialect from \language\l@british -)) -(C:\Users\ldecicco\AppData\Roaming\MiKTeX\2.9\tex\latex\preprint\authblk.sty -Package: authblk 2009/11/18 1.3 (PWD) -\affilsep=\skip49 -\@affilsep=\skip50 -\c@Maxaffil=\count111 -\c@authors=\count112 -\c@affil=\count113 -) -(C:\Users\ldecicco\AppData\Roaming\MiKTeX\2.9\tex\latex\mdwtools\footnote.sty -Package: footnote 1997/01/28 1.13 Save footnotes around boxes -\fn@notes=\box28 -\fn@width=\dimen116 -) -(C:\Users\ldecicco\AppData\Roaming\MiKTeX\2.9\tex\latex\placeins\placeins.sty -Package: placeins 2005/04/18 v 2.2 -) -(C:/PROGRA~1/R/R-30~1.0/share/texmf/tex/latex\Sweave.sty -Package: Sweave - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\ifthen.sty" -Package: ifthen 2001/05/26 v1.1c Standard LaTeX ifthen package (DPC) -) -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\graphics\graphicx.sty" -Package: graphicx 1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR) - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\graphics\graphics.sty" -Package: graphics 2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR) - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\graphics\trig.sty" -Package: trig 1999/03/16 v1.09 sin cos tan (DPC) -) -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\00miktex\graphics.cfg" -File: graphics.cfg 2007/01/18 v1.5 graphics configuration of teTeX/TeXLive -) -Package graphics Info: Driver file: pdftex.def on input line 91. - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\pdftex-def\pdftex.def" -File: pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX -\Gread@gobject=\count114 -)) -\Gin@req@height=\dimen117 -\Gin@req@width=\dimen118 -) -(C:\Users\ldecicco\AppData\Roaming\MiKTeX\2.9\tex\latex\fancyvrb\fancyvrb.sty -Package: fancyvrb 2008/02/07 - -Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix -<2008/02/07> (tvz) -\FV@CodeLineNo=\count115 -\FV@InFile=\read1 -\FV@TabBox=\box29 -\c@FancyVerbLine=\count116 -\FV@StepNumber=\count117 -\FV@OutFile=\write3 -) -(C:\Users\ldecicco\AppData\Roaming\MiKTeX\2.9\tex\latex\upquote\upquote.sty -Package: upquote 2012/04/19 v1.3 upright-quote and grave-accent glyphs in verba -tim - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\textcomp.sty" -Package: textcomp 2005/09/27 v1.99g Standard LaTeX package -Package textcomp Info: Sub-encoding information: -(textcomp) 5 = only ISO-Adobe without \textcurrency -(textcomp) 4 = 5 + \texteuro -(textcomp) 3 = 4 + \textohm -(textcomp) 2 = 3 + \textestimated + \textcurrency -(textcomp) 1 = TS1 - \textcircled - \t -(textcomp) 0 = TS1 (full) -(textcomp) Font families with sub-encoding setting implement -(textcomp) only a restricted character set as indicated. -(textcomp) Family '?' is the default used for unknown fonts. -(textcomp) See the documentation for details. -Package textcomp Info: Setting ? sub-encoding to TS1/1 on input line 71. - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\ts1enc.def" -File: ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file -) -LaTeX Info: Redefining \oldstylenums on input line 266. -Package textcomp Info: Setting cmr sub-encoding to TS1/0 on input line 281. -Package textcomp Info: Setting cmss sub-encoding to TS1/0 on input line 282. -Package textcomp Info: Setting cmtt sub-encoding to TS1/0 on input line 283. -Package textcomp Info: Setting cmvtt sub-encoding to TS1/0 on input line 284. -Package textcomp Info: Setting cmbr sub-encoding to TS1/0 on input line 285. -Package textcomp Info: Setting cmtl sub-encoding to TS1/0 on input line 286. -Package textcomp Info: Setting ccr sub-encoding to TS1/0 on input line 287. -Package textcomp Info: Setting ptm sub-encoding to TS1/4 on input line 288. -Package textcomp Info: Setting pcr sub-encoding to TS1/4 on input line 289. -Package textcomp Info: Setting phv sub-encoding to TS1/4 on input line 290. -Package textcomp Info: Setting ppl sub-encoding to TS1/3 on input line 291. -Package textcomp Info: Setting pag sub-encoding to TS1/4 on input line 292. -Package textcomp Info: Setting pbk sub-encoding to TS1/4 on input line 293. -Package textcomp Info: Setting pnc sub-encoding to TS1/4 on input line 294. -Package textcomp Info: Setting pzc sub-encoding to TS1/4 on input line 295. -Package textcomp Info: Setting bch sub-encoding to TS1/4 on input line 296. -Package textcomp Info: Setting put sub-encoding to TS1/5 on input line 297. -Package textcomp Info: Setting uag sub-encoding to TS1/5 on input line 298. -Package textcomp Info: Setting ugq sub-encoding to TS1/5 on input line 299. -Package textcomp Info: Setting ul8 sub-encoding to TS1/4 on input line 300. -Package textcomp Info: Setting ul9 sub-encoding to TS1/4 on input line 301. -Package textcomp Info: Setting augie sub-encoding to TS1/5 on input line 302. -Package textcomp Info: Setting dayrom sub-encoding to TS1/3 on input line 303. -Package textcomp Info: Setting dayroms sub-encoding to TS1/3 on input line 304. - -Package textcomp Info: Setting pxr sub-encoding to TS1/0 on input line 305. -Package textcomp Info: Setting pxss sub-encoding to TS1/0 on input line 306. -Package textcomp Info: Setting pxtt sub-encoding to TS1/0 on input line 307. -Package textcomp Info: Setting txr sub-encoding to TS1/0 on input line 308. -Package textcomp Info: Setting txss sub-encoding to TS1/0 on input line 309. -Package textcomp Info: Setting txtt sub-encoding to TS1/0 on input line 310. -Package textcomp Info: Setting lmr sub-encoding to TS1/0 on input line 311. -Package textcomp Info: Setting lmdh sub-encoding to TS1/0 on input line 312. -Package textcomp Info: Setting lmss sub-encoding to TS1/0 on input line 313. -Package textcomp Info: Setting lmssq sub-encoding to TS1/0 on input line 314. -Package textcomp Info: Setting lmvtt sub-encoding to TS1/0 on input line 315. -Package textcomp Info: Setting qhv sub-encoding to TS1/0 on input line 316. -Package textcomp Info: Setting qag sub-encoding to TS1/0 on input line 317. -Package textcomp Info: Setting qbk sub-encoding to TS1/0 on input line 318. -Package textcomp Info: Setting qcr sub-encoding to TS1/0 on input line 319. -Package textcomp Info: Setting qcs sub-encoding to TS1/0 on input line 320. -Package textcomp Info: Setting qpl sub-encoding to TS1/0 on input line 321. -Package textcomp Info: Setting qtm sub-encoding to TS1/0 on input line 322. -Package textcomp Info: Setting qzc sub-encoding to TS1/0 on input line 323. -Package textcomp Info: Setting qhvc sub-encoding to TS1/0 on input line 324. -Package textcomp Info: Setting futs sub-encoding to TS1/4 on input line 325. -Package textcomp Info: Setting futx sub-encoding to TS1/4 on input line 326. -Package textcomp Info: Setting futj sub-encoding to TS1/4 on input line 327. -Package textcomp Info: Setting hlh sub-encoding to TS1/3 on input line 328. -Package textcomp Info: Setting hls sub-encoding to TS1/3 on input line 329. -Package textcomp Info: Setting hlst sub-encoding to TS1/3 on input line 330. -Package textcomp Info: Setting hlct sub-encoding to TS1/5 on input line 331. -Package textcomp Info: Setting hlx sub-encoding to TS1/5 on input line 332. -Package textcomp Info: Setting hlce sub-encoding to TS1/5 on input line 333. -Package textcomp Info: Setting hlcn sub-encoding to TS1/5 on input line 334. -Package textcomp Info: Setting hlcw sub-encoding to TS1/5 on input line 335. -Package textcomp Info: Setting hlcf sub-encoding to TS1/5 on input line 336. -Package textcomp Info: Setting pplx sub-encoding to TS1/3 on input line 337. -Package textcomp Info: Setting pplj sub-encoding to TS1/3 on input line 338. -Package textcomp Info: Setting ptmx sub-encoding to TS1/4 on input line 339. -Package textcomp Info: Setting ptmj sub-encoding to TS1/4 on input line 340. -)) -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\fontenc.sty" -Package: fontenc 2005/09/27 v1.99g Standard LaTeX package - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\t1enc.def" -File: t1enc.def 2005/09/27 v1.99g Standard LaTeX file -LaTeX Font Info: Redeclaring font encoding T1 on input line 43. -)) -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\ae\ae.sty" -Package: ae 2001/02/12 1.3 Almost European Computer Modern - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\fontenc.sty" -Package: fontenc 2005/09/27 v1.99g Standard LaTeX package - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\t1enc.def" -File: t1enc.def 2005/09/27 v1.99g Standard LaTeX file -LaTeX Font Info: Redeclaring font encoding T1 on input line 43. -) -LaTeX Font Info: Try loading font information for T1+aer on input line 100. - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\ae\t1aer.fd" -File: t1aer.fd 1997/11/16 Font definitions for T1/aer. -)))) -(D:\LADData\RCode\dataRetrieval\inst\doc\dataRetrieval.aux) -LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 44. -LaTeX Font Info: ... okay on input line 44. -LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 44. -LaTeX Font Info: ... okay on input line 44. -LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 44. -LaTeX Font Info: ... okay on input line 44. -LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 44. -LaTeX Font Info: ... okay on input line 44. -LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 44. -LaTeX Font Info: ... okay on input line 44. -LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 44. -LaTeX Font Info: ... okay on input line 44. -LaTeX Font Info: Checking defaults for PD1/pdf/m/n on input line 44. -LaTeX Font Info: ... okay on input line 44. -LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 44. -LaTeX Font Info: Try loading font information for TS1+cmr on input line 44. - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\ts1cmr.fd" -File: ts1cmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions -) -LaTeX Font Info: ... okay on input line 44. -\AtBeginShipoutBox=\box30 -Package hyperref Info: Link coloring OFF on input line 44. - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\hyperref\nameref.sty" -Package: nameref 2010/04/30 v2.40 Cross-referencing by name of section - -("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\oberdiek\gettitlestring.sty" -Package: gettitlestring 2010/12/03 v1.4 Cleanup title references (HO) -) -\c@section@level=\count118 -) -LaTeX Info: Redefining \ref on input line 44. -LaTeX Info: Redefining \pageref on input line 44. -LaTeX Info: Redefining \nameref on input line 44. - -(D:\LADData\RCode\dataRetrieval\inst\doc\dataRetrieval.out) -(D:\LADData\RCode\dataRetrieval\inst\doc\dataRetrieval.out) -\@outlinefile=\write4 - -(C:\Users\ldecicco\AppData\Roaming\MiKTeX\2.9\tex\context\base\supp-pdf.mkii -[Loading MPS to PDF converter (version 2006.09.02).] -\scratchcounter=\count119 -\scratchdimen=\dimen119 -\scratchbox=\box31 -\nofMPsegments=\count120 -\nofMParguments=\count121 -\everyMPshowfont=\toks20 -\MPscratchCnt=\count122 -\MPscratchDim=\dimen120 -\MPnumerator=\count123 -\makeMPintoPDFobject=\count124 -\everyMPtoPDFconversion=\toks21 -) (D:\LADData\RCode\dataRetrieval\inst\doc\dataRetrieval-concordance.tex) -(D:\LADData\RCode\dataRetrieval\inst\doc\dataRetrieval.toc -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[1 - -{C:/Users/ldecicco/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}]) -\tf@toc=\write5 -LaTeX Font Info: Try loading font information for T1+aett on input line 62. - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\ae\t1aett.fd" -File: t1aett.fd 1997/11/16 Font definitions for T1/aett. -) -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[2] -Overfull \hbox (22.21066pt too wide) in paragraph at lines 82--83 -[][]$\T1/aett/m/n/10.95 http : / / nwis . waterdata . usgs . gov / usa / nwis / - pmcodes ? radio _ pm _ search = param _ group&pm _$ - [] - - -Overfull \hbox (23.424pt too wide) in paragraph at lines 82--83 -$\T1/aett/m/n/10.95 group = All + -[]-[] + include + all + parameter + groups&p -m _ search = &casrn _ search = &srsname _ search =$ - [] - - -Overfull \hbox (68.32622pt too wide) in paragraph at lines 82--83 -$\T1/aett/m/n/10.95 &format = html _ table&show = parameter _ group _ nm&show = - parameter _ nm&show = casrn&show = srsname&show =$ - [] - - -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[3] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[4] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[5] -Overfull \hbox (3.57079pt too wide) in paragraph at lines 232--243 - [][] - [] - - -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[6] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[7] <dataRetrieval-fig1.pdf, id=224, 433.62pt x 289.08pt> -File: dataRetrieval-fig1.pdf Graphic file (type pdf) - -<use dataRetrieval-fig1.pdf> -Package pdftex.def Info: dataRetrieval-fig1.pdf used on input line 335. -(pdftex.def) Requested size: 358.46039pt x 238.98355pt. - -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[8 <D:/LADData/RCode/dataRetrieval/inst/doc/dataRetrieval-fig1.pdf>] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[9] <dataRetrieval-fig2.pdf, id=243, 433.62pt x 289.08pt> -File: dataRetrieval-fig2.pdf Graphic file (type pdf) - -<use dataRetrieval-fig2.pdf> -Package pdftex.def Info: dataRetrieval-fig2.pdf used on input line 393. -(pdftex.def) Requested size: 358.46039pt x 238.98355pt. - -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[10 <D:/LADData/RCode/dataRetrieval/inst/doc/dataRetrieval-fig2.pdf>] -<dataRetrieval-fig3.pdf, id=257, 433.62pt x 289.08pt> -File: dataRetrieval-fig3.pdf Graphic file (type pdf) - -<use dataRetrieval-fig3.pdf> -Package pdftex.def Info: dataRetrieval-fig3.pdf used on input line 439. -(pdftex.def) Requested size: 358.46039pt x 238.98355pt. - -Overfull \hbox (0.79091pt too wide) in paragraph at lines 450--451 -\T1/aer/m/n/10.95 EPA) or NWIS database. Since STORET does not use USGS pa-ram- -e-ter codes, a \T1/aett/m/n/10.95 "\T1/aer/m/n/10.95 characteristic - [] - -LaTeX Font Info: Try loading font information for TS1+aett on input line 454 -. -(C:/PROGRA~1/R/R-30~1.0/share/texmf/tex/latex\ts1aett.fd -File: ts1aett.fd -) -LaTeX Font Info: Try loading font information for TS1+cmtt on input line 454 -. - -("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\ts1cmtt.fd" -File: ts1cmtt.fd 1999/05/25 v2.5h Standard LaTeX font definitions -) -LaTeX Font Info: Font shape `TS1/aett/m/sl' in size <10.95> not available -(Font) Font shape `TS1/cmtt/m/sl' tried instead on input line 454. - - -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[11 <D:/LADData/RCode/dataRetrieval/inst/doc/dataRetrieval-fig3.pdf>] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[12] -Underfull \hbox (badness 10000) in paragraph at lines 532--550 - - [] - - -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[13] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[14] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[15] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[16] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[17] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[18] <dataRetrieval-figegretEx.pdf, id=308, 433.62pt x 433.62pt> -File: dataRetrieval-figegretEx.pdf Graphic file (type pdf) - -<use dataRetrieval-figegretEx.pdf> -Package pdftex.def Info: dataRetrieval-figegretEx.pdf used on input line 771. -(pdftex.def) Requested size: 358.46039pt x 358.47534pt. - -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[19] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[20 <D:/LADData/RCode/dataRetrieval/inst/doc/dataRetrieval-figegretEx.pdf>] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[21 - -] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[22] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[23] -Overfull \vbox (15.16835pt too high) has occurred while \output is active [] - - -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[24] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[25] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[26] -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[27 - -] <table1.png, id=357, 554.07pt x 125.71968pt> -File: table1.png Graphic file (type png) - <use table1.png> -Package pdftex.def Info: table1.png used on input line 1069. -(pdftex.def) Requested size: 358.46039pt x 81.33507pt. - -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[28 <D:/LADData/RCode/dataRetrieval/inst/doc/table1.png>] -Package atveryend Info: Empty hook `BeforeClearDocument' on input line 1091. - -Overfull \vbox (21.68121pt too high) has occurred while \output is active [] - - -[29 - -] -Package atveryend Info: Empty hook `AfterLastShipout' on input line 1091. - (D:\LADData\RCode\dataRetrieval\inst\doc\dataRetrieval.aux) -Package atveryend Info: Executing hook `AtVeryEndDocument' on input line 1091. -Package atveryend Info: Executing hook `AtEndAfterFileList' on input line 1091. - -Package rerunfilecheck Info: File `dataRetrieval.out' has not changed. -(rerunfilecheck) Checksum: 3B1480473EC95CC4090ED48BB3268644;2119. - ) -Here is how much of TeX's memory you used: - 7545 strings out of 494045 - 108388 string characters out of 3145961 - 194722 words of memory out of 3000000 - 10596 multiletter control sequences out of 15000+200000 - 45443 words of font info for 92 fonts, out of 3000000 for 9000 - 715 hyphenation exceptions out of 8191 - 35i,12n,28p,912b,489s stack positions out of 5000i,500n,10000p,200000b,50000s - <C:\Users\ldecicco\AppData\Local\MiKTeX\2.9\fonts\pk\ljfour\jknappen\ec\dpi6 -00\tcst1095.pk><C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/public/amsfonts/c -m/cmbx10.pfb><C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/ -cmbx12.pfb><C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cm -mi10.pfb><C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr1 -0.pfb><C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr12.p -fb><C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr17.pfb> -<C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr6.pfb><C:/ -Program Files (x86)/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr7.pfb><C:/Prog -ram Files (x86)/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr8.pfb><C:/Program -Files (x86)/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr9.pfb><C:/Program File -s (x86)/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmsltt10.pfb><C:/Program File -s (x86)/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmti10.pfb><C:/Program Files -(x86)/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmtt10.pfb> -Output written on dataRetrieval.pdf (29 pages, 396695 bytes). -PDF statistics: - 451 PDF objects out of 1000 (max. 8388607) - 83 named destinations out of 1000 (max. 500000) - 270 words of extra memory for PDF output out of 10000 (max. 10000000) - diff --git a/inst/doc/dataRetrieval.synctex.gz b/inst/doc/dataRetrieval.synctex.gz deleted file mode 100644 index 759c83a846a18aa817c984f797ce8a708014c594..0000000000000000000000000000000000000000 Binary files a/inst/doc/dataRetrieval.synctex.gz and /dev/null differ diff --git a/inst/doc/dataRetrieval.tex b/inst/doc/dataRetrieval.tex deleted file mode 100644 index 433b28a446f2ce3b4ebcd6b57d20e29f1bd0ca31..0000000000000000000000000000000000000000 --- a/inst/doc/dataRetrieval.tex +++ /dev/null @@ -1,1093 +0,0 @@ -%\VignetteIndexEntry{Introduction to the dataRetrieval package} -%\VignetteDepends{} -%\VignetteSuggests{} -%\VignetteImports{} -%\VignettePackage{} - -\documentclass[a4paper,11pt]{article} - -\usepackage{amsmath} -\usepackage{times} -\usepackage{hyperref} -\usepackage[numbers, round]{natbib} -\usepackage[american]{babel} -\usepackage{authblk} -\usepackage{footnote} -\usepackage{placeins} -\renewcommand\Affilfont{\itshape\small} -\usepackage{Sweave} -\renewcommand{\topfraction}{0.85} -\renewcommand{\textfraction}{0.1} -\usepackage{graphicx} - - -\textwidth=6.2in -\textheight=8.5in -\parskip=.3cm -\oddsidemargin=.1in -\evensidemargin=.1in -\headheight=-.3in - -%------------------------------------------------------------ -% newcommand -%------------------------------------------------------------ -\newcommand{\scscst}{\scriptscriptstyle} -\newcommand{\scst}{\scriptstyle} -\newcommand{\Robject}[1]{{\texttt{#1}}} -\newcommand{\Rfunction}[1]{{\texttt{#1}}} -\newcommand{\Rclass}[1]{\textit{#1}} -\newcommand{\Rpackage}[1]{\textit{#1}} -\newcommand{\Rexpression}[1]{\texttt{#1}} -\newcommand{\Rmethod}[1]{{\texttt{#1}}} -\newcommand{\Rfunarg}[1]{{\texttt{#1}}} - -\begin{document} -\input{dataRetrieval-concordance} - -%------------------------------------------------------------ -\title{The dataRetrieval R package} -%------------------------------------------------------------ -\author[1]{Laura De Cicco} -\author[1]{Robert Hirsch} -\affil[1]{United States Geological Survey} - - - -\maketitle -\tableofcontents - -%------------------------------------------------------------ -\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 R package: Exploration and Graphics for RivEr Trends (EGRET). See: \url{https://github.com/USGS-R/EGRET/wiki} for information on EGRET. EGRET is designed to provide analysis of water quality data sets using the WRTDS method of data analysis (WRTDS is Weighted Regressions on Time, Discharge and Season) as well as analysis of streamflow trends using robust time-series smoothing techniques. Both of these capabilities provide both tabular and graphical analyses of long-term data sets. - - -The dataRetrieval package is designed to retrieve many of the major data types of USGS hydrologic data that are available on the web, but also allows users to make use of other data that they supply from spreadsheets. Section 2 provides examples of how one can obtain raw data from USGS sources on the web and ingest them into data frames within the R environment. The functionality described in section 2 is for general use and is not tailored for the specific uses of the EGRET package. The functionality described in section 3 is tailored specifically to obtaining input from the web and structuring them specifically for use in the EGRET package. The functionality described in section 4 is for converting hydrologic data from user-supplied spreadsheets and structuring them specifically for use in the EGRET package. - -For information on getting started in R and installing the package, see Appendix (\ref{sec:appendix1}): Getting Started. - - -%------------------------------------------------------------ -\section{General USGS Web Retrievals} -%------------------------------------------------------------ -In this section, we will run through 5 examples, documenting how to get raw data from the web. This includes site information (\ref{sec:usgsSite}), measured parameter information (\ref{sec:usgsParams}), historical daily values(\ref{sec:usgsDaily}), real-time (unit) values (\ref{sec:usgsRT}), and water quality data (\ref{sec:usgsWQP}) or (\ref{sec:usgsSTORET}). We will use the Choptank River near Greensboro, MD as an example. The site-ID for this gage station is 01491000. Daily discharge measurements are available as far back as 1948. Additionally, forms of nitrate have been measured dating back to 1964. The functions/examples in this section are for raw data retrieval. This may or may not be the easiest data to work with. In the next section, we will use functions that retrieve and process the data in a dataframe that may prove more friendly for R analysis. - -%------------------------------------------------------------ -\subsection{Introduction} -%------------------------------------------------------------ -The United States Geological Survey organizes their hydrological data in standard structure. Streamgages are located throughout the United States, and each streamgage has a unique ID. Often (but not always), these ID's are 8 digits. The first step to finding data is discoving this 8-digit ID. One potential tool for discovering data is Environmental Data Discovery and Transformation (EnDDaT): \url{http://cida.usgs.gov/enddat/}. Follow the example on the EnDDaT web page to learn how to discover USGS stations and available data from any location in the United States. - -Once the site-ID is known, the next required input for USGS data retrievals is the 'parameter code'. This is a 5-digit code that specifies what measured paramater is being requested. A complete list of possible USGS parameter codes can be found at: - -\url{http://nwis.waterdata.usgs.gov/usa/nwis/pmcodes?radio_pm_search=param_group&pm_group=All+--+include+all+parameter+groups&pm_search=&casrn_search=&srsname_search=&format=html_table&show=parameter_group_nm&show=parameter_nm&show=casrn&show=srsname&show=parameter_units} - -Not every station will measure all parameters. A short list of commonly measured parameters is shown in Table \ref{tab:params}. - - - -% latex table generated in R 3.0.0 by xtable 1.7-1 package -% Mon Apr 08 10:09:40 2013 -\begin{table}[!ht] -\centering -\caption{Common USGS Parameter Codes} -\label{tab:params} -\begin{tabular}{ll} - \hline -pCode & shortName \\ - \hline -00060 & Discharge [cfs] \\ - 00065 & Gage height [ft] \\ - 00010 & Temperature [C] \\ - 00045 & Precipitation [in] \\ - 00400 & pH \\ - \hline -\end{tabular} -\end{table} -For real-time data, the parameter code and site ID will suffice. For most variables that are measured on a continuous basis, the USGS stores the historical data as daily values. These daily values may be in the form of statistics such as the daily mean values, but they can also include daily maximums, minimums or medians. These different statistics are specified by a 5-digit \texttt{"}stat code\texttt{"}. A complete list of stat codes can be found here: - -\url{http://nwis.waterdata.usgs.gov/nwis/help/?read_file=stat&format=table} - -Some common stat codes are shown in Table \ref{tab:stat}. -% latex table generated in R 3.0.0 by xtable 1.7-1 package -% Mon Apr 08 10:09:40 2013 -\begin{table}[!ht] -\centering -\caption{Commonly found USGS Stat Codes} -\label{tab:stat} -\begin{tabular}{ll} - \hline -StatCode & shortName \\ - \hline -00001 & Maximum \\ - 00002 & Minimum \\ - 00003 & Mean \\ - 00008 & Median \\ - \hline -\end{tabular} -\end{table} -\FloatBarrier -%------------------------------------------------------------ -\subsection{Site Information} -\label{sec:usgsSite} -%------------------------------------------------------------ - -%------------------------------------------------------------ -\subsubsection{getSiteFileData} -\label{sec:usgsSiteFileData} -%------------------------------------------------------------ -Use the getSiteFileData function to obtain all of the information available for a particular USGS site such as full station name, drainage area, latitude, and longitude: - - -\begin{Schunk} -\begin{Sinput} -> library(dataRetrieval) -> # Site ID for Choptank River near Greensboro, MD -> siteNumber <- "01491000" -> ChoptankInfo <- getSiteFileData(siteNumber) -\end{Sinput} -\end{Schunk} - -A list of the available columns are found in Appendix \ref{sec:appendix2INFO}: INFO dataframe. Pulling out a specific example piece of information, in this case station name can be done as follows: - -\begin{Schunk} -\begin{Sinput} -> ChoptankInfo$station.nm -\end{Sinput} -\begin{Soutput} -[1] "CHOPTANK RIVER NEAR GREENSBORO, MD" -\end{Soutput} -\end{Schunk} -Site information is obtained from \url{http://waterservices.usgs.gov/rest/Site-Test-Tool.html} -\FloatBarrier -%------------------------------------------------------------ -\subsubsection{getDataAvailability} -\label{sec:usgsDataAvailability} -%------------------------------------------------------------ -To find out the available data at a particular USGS site, including measured parameters, period of record, and number of samples (count), use the getDataAvailability function: - -\begin{Schunk} -\begin{Sinput} -> # Continuing from the previous example: -> ChoptankAvailableData <- getDataAvailability(siteNumber) -> head(ChoptankAvailableData) -\end{Sinput} -\begin{Soutput} - parameter_cd statCd startDate endDate count service -2 00010 00001 1988-10-01 2012-06-24 940 dv -3 00010 00002 2010-10-01 2012-06-24 575 dv -4 00010 00003 2010-10-01 2012-06-24 575 dv -5 00060 00003 1948-01-01 2013-04-07 23839 dv -6 00095 00001 2010-10-01 2012-06-24 551 dv -7 00095 00002 2010-10-01 2012-06-24 551 dv -\end{Soutput} -\end{Schunk} - -There is an additional argument to the getDataAvailability called longNames, which defaults to FALSE. Setting longNames to TRUE will cause the function to make a web service call for each parameter and return expanded information on that parameter. Currently, this is a very slow process because each parameter code makes a unique web service call. If the site does not have many measured parameters, setting longNames to TRUE is reasonable. - -It is also possible to only request parameter information for a subset of variables. In the following example, we retrieve just the daily mean parameter information from the Choptank data availability dataframe (excluding all unit value and water quality values). getMultipleParameterNames is the function that is embedded in the getDataAvailability, but here can be used as a standalone function. - - -\begin{Schunk} -\begin{Sinput} -> # Continuing from the previous example: -> # This pulls out just the daily data: -> ChoptankDailyData <- subset(ChoptankAvailableData,"dv" == service) -> # This pulls out the mean: -> ChoptankDailyData <- subset(ChoptankDailyData,"00003" == statCd) -> #Now, make a call to get all of the parameter information: -> pCodeINFO <- getMultipleParameterNames(ChoptankDailyData$parameter_cd) -\end{Sinput} -\begin{Soutput} -Percent complete: -20 40 60 80 100 -\end{Soutput} -\begin{Sinput} -> #Merge the available dataframe with the parameter information dataframe: -> ChoptankDailyData <- merge(ChoptankDailyData,pCodeINFO,by="parameter_cd") -\end{Sinput} -\end{Schunk} - -The daily data at the Choptank River site can be displayed in a \LaTeX table using the xtable package. See Appendix \ref{app:createWordTable} for instructions on converting an R dataframe to a table in Microsoft Excel or Word. - -\begin{Schunk} -\begin{Sinput} -> tableData <- with(ChoptankDailyData, - data.frame(shortName=srsname, - Start=as.character(startDate), - End=as.character(endDate), - Count=as.character(count), - Units=parameter_units) - ) -> data.table <- xtable(tableData,label="tab:gda", - caption="Daily mean data availabile at the Choptank River") -> print(data.table, - caption.placement="top",include.rownames=FALSE) -\end{Sinput} -% latex table generated in R 3.0.0 by xtable 1.7-1 package -% Mon Apr 08 10:09:46 2013 -\begin{table}[ht] -\centering -\caption{Daily mean data availabile at the Choptank River} -\label{tab:gda} -\begin{tabular}{lllll} - \hline -shortName & Start & End & Count & Units \\ - \hline -Temperature, water & 2010-10-01 & 2012-06-24 & 575 & deg C \\ - Stream flow, mean. daily & 1948-01-01 & 2013-04-07 & 23839 & cfs \\ - Specific conductance & 2010-10-01 & 2012-06-24 & 551 & uS/cm @25C \\ - Suspended sediment concentration (SSC) & 1980-10-01 & 1991-09-30 & 3651 & mg/l \\ - Suspended sediment discharge & 1980-10-01 & 1991-09-30 & 3652 & tons/day \\ - \hline -\end{tabular} -\end{table}\end{Schunk} - - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Parameter Information} -\label{sec:usgsParams} -%------------------------------------------------------------ -To obtain all of the available information concerning a measured parameter, use the getParameterInfo function: -\begin{Schunk} -\begin{Sinput} -> # Using defaults: -> parameterCd <- "00618" -> parameterINFO <- getParameterInfo(parameterCd) -> colnames(parameterINFO) -\end{Sinput} -\begin{Soutput} -[1] "parameter_cd" "parameter_group_nm" "parameter_nm" -[4] "casrn" "srsname" "parameter_units" -\end{Soutput} -\end{Schunk} - -Pulling out a specific example piece of information, in this case parameter name can be done as follows: -\begin{Schunk} -\begin{Sinput} -> parameterINFO$parameter_nm -\end{Sinput} -\begin{Soutput} -[1] "Nitrate, water, filtered, milligrams per liter as nitrogen" -\end{Soutput} -\end{Schunk} -Parameter information is obtained from \url{http://nwis.waterdata.usgs.gov/nwis/pmcodes/} -\FloatBarrier -%------------------------------------------------------------ -\subsection{Daily Values} -\label{sec:usgsDaily} -%------------------------------------------------------------ -To obtain historic daily records of USGS data, use the retrieveNWISData function. The arguments for this function are siteNumber, parameterCd, startDate, endDate, statCd, and a logical (true/false) interactive. There are 2 default argument: statCd (defaults to \texttt{"}00003\texttt{"}), and interactive (defaults to TRUE). If you want to use the default values, you do not need to list them in the function call. Setting the \texttt{"}interactive\texttt{"} option to true will walk you through the function. It might make more sense to run large batch collections with the interactive option set to FALSE. - -The dates (start and end) need to be in the format \texttt{"}YYYY-MM-DD\texttt{"} (note: the user does need to include the quotes). Setting the start date to \texttt{"}\texttt{"} will indicate to the program to ask for the earliest date, setting the end date to \texttt{"}\texttt{"} will ask for the latest available date. - -\begin{Schunk} -\begin{Sinput} -> # Continuing with our Choptank River example -> parameterCd <- "00060" # Discharge (cfs) -> startDate <- "" # Will request earliest date -> endDate <- "" # Will request latest date -> discharge <- retrieveNWISData(siteNumber, parameterCd, startDate, endDate) -\end{Sinput} -\end{Schunk} - -The variable datetime is automatically imported as a Date. Each requested parameter has a value and remark code column. The names of these columns depend on the requested parameter and stat code combinations. USGS remark codes are often \texttt{"}A\texttt{"} (approved for publication) or \texttt{"}P\texttt{"} (provisional data subject to revision). A more complete list of remark codes can be found here: -\url{http://waterdata.usgs.gov/usa/nwis/help?codes_help} - -Another example that doesn't use the defaults would be a request for mean and maximum daily temperature and discharge in early 2012: -\begin{Schunk} -\begin{Sinput} -> parameterCd <- c("00010","00060") # Temperature and discharge -> statCd <- c("00001","00003") # Mean and maximum -> startDate <- "2012-01-01" -> endDate <- "2012-06-30" -> temperatureAndFlow <- retrieveNWISData(siteNumber, parameterCd, - startDate, endDate, StatCd=statCd,interactive=FALSE) -> -\end{Sinput} -\end{Schunk} - -Daily data is pulled from \url{http://waterservices.usgs.gov/rest/DV-Test-Tool.html}. - -An example of plotting the above data (Figure \ref{fig:TD}): - -\begin{Schunk} -\begin{Sinput} -> colnames <- names(temperatureAndFlow) -> with(temperatureAndFlow, plot( - get(colnames[3]), get(colnames[6]), - xlab="Date",ylab="Temperature [C]" - )) -> par(new=TRUE) -> with(temperatureAndFlow, plot( - get(colnames[3]), get(colnames[8]), - col="red",type="l",xaxt="n",yaxt="n",xlab="",ylab="",axes=FALSE - )) -> axis(4,col="red",col.axis="red") -> mtext("Discharge [cfs]",side=4,line=3,col="red") -> title(paste(ChoptankInfo$station.nm,"2012",sep=" ")) -\end{Sinput} -\end{Schunk} - - -\begin{figure} -\begin{center} -\includegraphics{dataRetrieval-fig1} -\end{center} -\caption{Temperature and discharge plot of Choptank River in 2012.} -\label{fig:TD} -\end{figure} - - -There are occasions where NWIS values are not reported as numbers, instead there might be text describing a certain event such as \texttt{"}Ice\texttt{"}. Any value that cannot be converted to a number will be reported as NA in this package. - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Unit Values} -\label{sec:usgsRT} -%------------------------------------------------------------ -Any data that are collected at regular time intervals (such as 15-minute or hourly) are known as \texttt{"}Unit Values\texttt{"} - many of these are delivered on a real time basis and very recent data (even less than an hour old in many cases) are available through the function retrieveUnitNWISData. Some of these Unit Values are available for the past several years, and some are only available for a recent time period such as 120 days or a year. Here is an example of a retrieval of such data. - -\begin{Schunk} -\begin{Sinput} -> parameterCd <- "00060" # Discharge (cfs) -> startDate <- "2012-05-12" -> # or use (yesterday): startDate <- as.character(Sys.Date()-1) -> endDate <- "2012-05-13" -> # or use (today): endDate <- as.character(Sys.Date()) -> dischargeToday <- retrieveUnitNWISData(siteNumber, parameterCd, - startDate, endDate) -\end{Sinput} -\end{Schunk} -Which produces the following dataframe: -\begin{Schunk} -\begin{Soutput} - agency site dateTime X02_00060_00011 X02_00060_00011_cd -1 USGS 01491000 2012-05-12 00:00:00 83 A -2 USGS 01491000 2012-05-12 00:15:00 83 A -3 USGS 01491000 2012-05-12 00:30:00 83 A -4 USGS 01491000 2012-05-12 00:45:00 83 A -5 USGS 01491000 2012-05-12 01:00:00 85 A -6 USGS 01491000 2012-05-12 01:15:00 83 A -\end{Soutput} -\end{Schunk} - -Note that time now becomes important, so the variable datetime is a POSIXct, and the time zone is included in a separate column. Data is pulled from \url{http://waterservices.usgs.gov/rest/IV-Test-Tool.html}. There are occasions where NWIS values are not reported as numbers, instead a common example is \texttt{"}Ice\texttt{"}. Any value that cannot be converted to a number will be reported as NA in this package. - -A simple plotting example is shown in Figure \ref{fig:RT}: -\begin{Schunk} -\begin{Sinput} -> colnames <- names(dischargeToday) -> with(dischargeToday, plot( - get(colnames[3]), get(colnames[4]), - ylab="Discharge [cfs]",xlab="" - )) -> title(ChoptankInfo$station.nm) -> -\end{Sinput} -\end{Schunk} -\newpage - -\begin{figure} -\begin{center} -\includegraphics{dataRetrieval-fig2} -\end{center} -\caption{Real-time discharge plot of Choptank River from May 12-13, 2012.} -\label{fig:RT} -\end{figure} - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Water Quality Values} -\label{sec:usgsWQP} -%------------------------------------------------------------ -To get USGS water quality data from water samples collected at the streamgage (as distinct from unit values collected through some type of automatic monitor) we can use the Water Quality Data Portal: \url{http://www.waterqualitydata.us/}. The raw data are obtained from the function getRawQWData, with the similar input arguments: siteNumber, parameterCd, startDate, endDate, and interactive. The difference is in parameterCd, in this function multiple parameters can be queried using a \texttt{"};\texttt{"} separator, and setting parameterCd to \texttt{"}\texttt{"} will return all of the measured observations. The raw data can be overwelming (see Appendix \ref{sec:appendix2WQP}), a simplified version of the data can be obtained using getQWData.There is a large amount of data returned for each observation. - - -\begin{Schunk} -\begin{Sinput} -> # Dissolved Nitrate parameter codes: -> parameterCd <- c("00618","71851") -> startDate <- "1979-10-11" -> endDate <- "2012-12-18" -> dissolvedNitrate <- getRawQWData(siteNumber, parameterCd, - startDate, endDate) -> dissolvedNitrateSimple <- getQWData(siteNumber, parameterCd, - startDate, endDate) -> names(dissolvedNitrateSimple) -\end{Sinput} -\begin{Soutput} -[1] "dateTime" "qualifier.00618" "value.00618" "qualifier.71851" -[5] "value.71851" -\end{Soutput} -\end{Schunk} -Note that in this dataframe, datetime is imported as Dates (no times are included), and the qualifier is either blank or \texttt{"}\verb@<@\texttt{"} signifying a censored value. A plotting example is shown in Figure \ref{fig:nitrate}. - -\begin{Schunk} -\begin{Sinput} -> with(dissolvedNitrateSimple, plot( - dateTime, value.00618, - xlab="Date",ylab = paste(parameterINFO$srsname, - "[",parameterINFO$parameter_units,"]") - )) -> title(ChoptankInfo$station.nm) -\end{Sinput} -\end{Schunk} - -\begin{figure} -\begin{center} -\includegraphics{dataRetrieval-fig3} -\end{center} -\caption{Nitrate plot of Choptank River.} -\label{fig:nitrate} -\end{figure} - -\FloatBarrier -%------------------------------------------------------------ -\subsection{STORET Water Quality Retrievals} -\label{sec:usgsSTORET} -%------------------------------------------------------------ -There are additional data sets available on the Water Quality Data Portal (\url{http://www.waterqualitydata.us/}). These data sets can be housed in either the STORET (data from EPA) or NWIS database. Since STORET does not use USGS parameter codes, a \texttt{"}characteristic name\texttt{"} must be supplied. The following example retrieves specific conductance from a DNR site in Wisconsin. - -\begin{Schunk} -\begin{Sinput} -> specificCond <- getWQPData('WIDNR_WQX-10032762', - 'Specific conductance', '', '') -> head(specificCond) -\end{Sinput} -\begin{Soutput} - dateTime qualifier.Specific conductance value.Specific conductance -1 2011-02-14 1360 -2 2011-02-17 1930 -3 2011-03-03 1240 -4 2011-03-10 1480 -5 2011-03-29 1130 -6 2011-04-07 1200 -\end{Soutput} -\end{Schunk} - -\FloatBarrier -%------------------------------------------------------------ -\subsection{URL Construction} -\label{sec:usgsURL} -%------------------------------------------------------------ -There may be times when you might be interested in seeing the URL (web address) that was used to obtain the raw data. The constructNWISURL function returns the URL. Aside from input variables that have already been described, there is a new argument \texttt{"}service\texttt{"}. The service argument can be \texttt{"}dv\texttt{"} (daily values), \texttt{"}uv\texttt{"} (unit values), \texttt{"}qw\texttt{"} (NWIS water quality values), or \texttt{"}wqp\texttt{"} (general Water Quality Portal values). - - -\begin{Schunk} -\begin{Sinput} -> # Dissolved Nitrate parameter codes: -> pCode <- c("00618","71851") -> startDate <- "1964-06-11" -> endDate <- "2012-12-18" -> url_qw <- constructNWISURL(siteNumber,pCode,startDate,endDate,'qw') -> url_dv <- constructNWISURL(siteNumber,"00060",startDate,endDate,'dv',statCd="00003") -> url_uv <- constructNWISURL(siteNumber,"00060",startDate,endDate,'uv') -\end{Sinput} -\end{Schunk} - -\FloatBarrier -%------------------------------------------------------------ -\section{Data Retrievals Structured For Use In The EGRET Package} -%------------------------------------------------------------ -Rather than using the raw data as retrieved by the web, the dataRetrieval package also includes functions that return the data in a structure that has been designed to work with the EGRET R package (\url{https://github.com/USGS-R/EGRET/wiki}). In general, these dataframes may be much more 'R-friendly' than the raw data, and will contain additional date information that allows for efficient data analysis. - -In this section, we use 3 dataRetrieval functions to get sufficient data to perform an EGRET analysis. We will continue analyzing the Choptank River. We will be retrieving essentially the same data that were retrieved in the previous section, but in this case it will be structured into three EGRET-specific dataframes. The daily discharge data will be placed in a dataframe called Daily. The nitrate sample data will be placed in a dataframe called Sample. The data about the site and the parameter will be placed in a dataframe called INFO. Although these dataframes were designed to work with the EGRET R package, they can be very useful for a wide range of hydrologic studies that don't use EGRET. - -%------------------------------------------------------------ -\subsection{INFO Data} -%------------------------------------------------------------ -The function to obtain metadata, or data about the streamgage and measured parameters is getMetaData. This function combines getSiteFileData and getParameterInfo, producing one dataframe called INFO. - -\begin{Schunk} -\begin{Sinput} -> parameterCd <- "00618" -> INFO <-getMetaData(siteNumber,parameterCd, interactive=FALSE) -\end{Sinput} -\end{Schunk} - -Column names in the INFO dataframe are listed in Appendix 2 (\ref{sec:appendix2INFO}). - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Daily Data} -%------------------------------------------------------------ -The function to obtain the daily values (discharge in this case) is getDVData. It requires the inputs siteNumber, ParameterCd, StartDate, EndDate, interactive, and convert. Most of these arguments are described in the previous section, however \texttt{"}convert\texttt{"} is a new argument (defaults to TRUE), and it tells the program to convert the values from cubic feet per second (cfs) to cubic meters per second (cms). For EGRET applications with NWIS web retrieval, do not use this argument (the default is TRUE), EGRET assumes that discharge is always in cubic meters per second. If you don't want this conversion and are not using EGRET, set convert=FALSE in the function call. - -\begin{Schunk} -\begin{Sinput} -> siteNumber <- "01491000" -> startDate <- "2000-01-01" -> endDate <- "2013-01-01" -> # This call will get NWIS data that is in cfs, and convert it -> # to cms since we didn't override the default in the convert argument: -> Daily <- getDVData(siteNumber, "00060", startDate, endDate,interactive=FALSE) -\end{Sinput} -\end{Schunk} - -Details of the Daily dataframe are listed below: - -% latex table generated in R 3.0.0 by xtable 1.7-1 package -% Mon Apr 08 10:09:57 2013 -\begin{tabular}{llll} - \hline -ColumnName & Type & Description & Units \\ - \hline -Date & Date & Date & date \\ - Q & number & Discharge & cms \\ - Julian & number & Number of days since January 1, 1850 & days \\ - Month & integer & Month of the year [1-12] & months \\ - Day & integer & Day of the year [1-366] & days \\ - DecYear & number & Decimal year & years \\ - MonthSeq & integer & Number of months since January 1, 1850 & months \\ - Qualifier & string & Qualifing code & character \\ - i & integer & Index of days from the start of the data frame & days \\ - LogQ & number & Natural logarithm of Q & numeric \\ - Q7 & number & 7 day running average of Q & cms \\ - Q30 & number & 30 running average of Q & cms \\ - \hline -\end{tabular}\\* - -If there are discharge values of zero, the code will add a small constant to all of the daily discharges. This constant is 0.001 times the mean discharge. The code will also report on the number of zero values and the size of the constant. EGRET should only be used if the number of zero values is a very small fraction of the total days in the record (say less than 0.1\% of the days). Columns Q7 and Q30 are the 7 and 30 day running averages for the 7 or 30 days ending on this specific date. - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Sample Data} -%------------------------------------------------------------ -The function to obtain sample data from the water quality portal is getSampleData. The arguments for this function are also siteNumber, ParameterCd, StartDate, EndDate, interactive. These are the same inputs as getRawQWData or getQWData as described in the previous section. - -\begin{Schunk} -\begin{Sinput} -> Sample <-getSampleData(siteNumber,parameterCd, - startDate, endDate,interactive=FALSE) -\end{Sinput} -\end{Schunk} - -Details of the Sample dataframe are listed below: - -% latex table generated in R 3.0.0 by xtable 1.7-1 package -% Mon Apr 08 10:09:58 2013 -\begin{table}[!ht] -\centering -\caption{Sample dataframe} -\begin{tabular}{llll} - \hline -ColumnName & Type & Description & Units \\ - \hline -Date & Date & Date & date \\ - ConcLow & number & Lower limit of concentration & mg/L \\ - ConcHigh & number & Upper limit of concentration & mg/L \\ - Uncen & integer & Uncensored data (1=true, 0=false) & integer \\ - ConcAve & number & Average of ConcLow and ConcHigh & mg/L \\ - Julian & number & Number of days since January 1, 1850 & days \\ - Month & integer & Month of the year [1-12] & months \\ - Day & integer & Day of the year [1-366] & days \\ - DecYear & number & Decimal year & years \\ - MonthSeq & integer & Number of months since January 1, 1850 & months \\ - SinDY & number & Sine of DecYear & numeric \\ - CosDY & number & Cosine of DecYear & numeric \\ - Q \footnotemark[1] & number & Discharge & cms \\ - LogQ \footnotemark[1] & number & Natural logarithm of flow & numeric \\ - \hline -\end{tabular} -\end{table}\footnotetext[1]{Flow columns are populated from data in the Daily dataframe after calling the mergeReport function.} - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Censored Values: Summation Explanation} -%------------------------------------------------------------ -In the typical case where none of the data are censored (that is, no values are reported as \texttt{"}less-than\texttt{"} values) the ConcLow = ConcHigh = ConcAve all of which are equal to the reported value and Uncen=0. In the typical form of censoring where a value is reported as less than the reporting limit, then ConcLow = NA, ConcHigh = reporting limit, ConcAve = 0.5 * reporting limit, and Uncen = 1. - -As an example to understand how the dataRetrieval package handles a more complex censoring problem, let us say that in 2004 and earlier, we computed a total phosphorus (tp) as the sum of dissolved phosphorus (dp) and particulate phosphorus (pp). From 2005 and onward, we have direct measurements of total phosphorus (tp). A small subset of this fictional data looks like this: - -\begin{center} - -% latex table generated in R 3.0.0 by xtable 1.7-1 package -% Mon Apr 08 10:09:58 2013 -\begin{tabular}{llrlrlr} - \hline -cdate & rdp & dp & rpp & pp & rtp & tp \\ - \hline -2003-02-15 & & 0.02 & & 0.50 & & \\ - 2003-06-30 & $<$ & 0.01 & & 0.30 & & \\ - 2004-09-15 & $<$ & 0.00 & $<$ & 0.20 & & \\ - 2005-01-30 & & & & & & 0.43 \\ - 2005-05-30 & & & & & $<$ & 0.05 \\ - 2005-10-30 & & & & & $<$ & 0.02 \\ - \hline -\end{tabular} -\end{center} - - -The dataRetrieval package will \texttt{"}add up\texttt{"} all the values in a given row to form the total for that sample. Thus, you only want to enter data that should be added together. For example, we might know the value for dp on 5/30/2005, but we don't want to put it in the table because under the rules of this data set, we are not suppose to add it in to the values in 2005. - -For every sample, the EGRET package requires a pair of numbers to define an interval in which the true value lies (ConcLow and ConcHigh). In a simple non-censored case (the reported value is above the detection limit), ConcLow equals ConcHigh and the interval collapses down to a single point.In a simple censored case, the value might be reported as <0.2, then ConcLow=NA and ConcHigh=0.2. We use NA instead of 0 as a way to elegantly handle future logarithm calculations. - -For the more complex example case, let us say dp is reported as <0.01 and pp is reported as 0.3. We know that the total must be at least 0.3 and could be as much as 0.31. Therefore, ConcLow=0.3 and ConcHigh=0.31. Another case would be if dp is reported as <0.005 and pp is reported <0.2. We know in this case that the true value could be as low as zero, but could be as high as 0.205. Therefore, in this case, ConcLow=NA and ConcHigh=0.205. The Sample dataframe for the example data is therefore: - -\begin{Schunk} -\begin{Soutput} - Date ConcLow ConcHigh Uncen ConcAve Julian Month Day DecYear MonthSeq -1 2003-02-15 0.520 0.520 1 0.520 55927 2 46 2003.124 1838 -2 2003-06-30 0.310 0.310 1 0.310 56062 6 181 2003.493 1842 -3 2004-09-15 0.205 0.205 1 0.205 56505 9 259 2004.706 1857 -4 2005-01-30 0.430 0.430 1 0.430 56642 1 30 2005.081 1861 -5 2005-05-30 0.050 0.050 1 0.050 56762 5 150 2005.408 1865 -6 2005-10-30 0.020 0.020 1 0.020 56915 10 303 2005.827 1870 - SinDY CosDY -1 0.70406552 0.7101350 -2 0.04290476 -0.9990792 -3 -0.96251346 -0.2712339 -4 0.48505985 0.8744810 -5 0.54391895 -0.8391378 -6 -0.88668032 0.4623830 -\end{Soutput} -\end{Schunk} - -\FloatBarrier -%------------------------------------------------------------ -\subsection{User-Generated Data Files} -%------------------------------------------------------------ -Aside from retrieving data from the USGS web services, the dataRetrieval package includes functions to generate the Daily and Sample data frame from local files. - -%------------------------------------------------------------ -\subsubsection{getDailyDataFromFile} -%------------------------------------------------------------ -getDailyDataFromFile will load a user-supplied text file and convert it to the Daily dataframe. The file should have two columns, the first dates, the second values. The dates should be formatted either mm/dd/yyyy or yyyy-mm-dd. Using a 4-digit year is required. This function has the following inputs: filePath, fileName,hasHeader (TRUE/FALSE), separator, qUnit, and interactive (TRUE/FALSE). filePath is a string that defines the path to your file. This can either be a full path, or path relative to your R working directory. The input fileName is a string that defines the file name (including the extension). - -Text files that contain this sort of data require some sort of a separator, for example, a 'csv' file (comma-separated value) file uses a comma to separate the date and value column. A tab delimited file would use a tab (\texttt{"}\verb@\t@\texttt{"}) rather than the comma (\texttt{"},\texttt{"}). The type of separator you use can be defined in the function call in the \texttt{"}separator\texttt{"} argument, the default is \texttt{"},\texttt{\texttt{"}}. Another function input is a logical variable: hasHeader. The default is TRUE. If your data does not have column names, set this variable to FALSE. - -Finally, qUnit is a numeric argument that defines the discharge units used in the input file. The default is qUnit = 1 which assumes discharge is in cubic feet per second. If the discharge in the file is already in cubic meters per second then set qUnit = 2. If it is in some other units (like liters per second or acre-feet per day), the user will have to pre-process the data with a unit conversion that changes it to either cubic feet per second or cubic meters per second. - -So, if you have a file called \texttt{"}ChoptankRiverFlow.txt\texttt{"} located in a folder called \texttt{"}RData\texttt{"} on the C drive (this is a Window's example), and the file is structured as follows (tab-separated): -\begin{verbatim} -date Qdaily -10/1/1999 107 -10/2/1999 85 -10/3/1999 76 -10/4/1999 76 -10/5/1999 113 -10/6/1999 98 -... -\end{verbatim} - -The call to open this file, convert the flow to cubic meters per second, and populate the Daily data frame would be: -\begin{Schunk} -\begin{Sinput} -> fileName <- "ChoptankRiverFlow.txt" -> filePath <- "C:/RData/" -> Daily <- getDailyDataFromFile(filePath,fileName,separator="\t",interactive=FALSE) -\end{Sinput} -\end{Schunk} - -\FloatBarrier -%------------------------------------------------------------ -\subsubsection{getSampleDataFromFile} -%------------------------------------------------------------ -Similarly to the previous section, getSampleDataFromFile will import a user-generated file and populate the Sample dataframe. The difference between sample data and flow data is that the code requires a third column that contains a remark code, either blank or \texttt{"}\verb@<@\texttt{"}, which will tell the program that the data was 'left-censored' (or, below the detection limit of the sensor). Therefore, the data is required to be in the form: date, remark, value. If multiple constituents are going to be used, the format can be date, remark\_A, value\_A, remark\_b, value\_b, etc... An example of a comma-delimited file would be: - -\begin{verbatim} -cdate;remarkCode;Nitrate -10/7/1999,,1.4 -11/4/1999,<,0.99 -12/3/1999,,1.42 -1/4/2000,,1.59 -2/3/2000,,1.54 -... -\end{verbatim} -The call to open this file, and populate the Sample dataframe would be: -\begin{Schunk} -\begin{Sinput} -> fileName <- "ChoptankRiverNitrate.csv" -> filePath <- "C:/RData/" -> Sample <- getSampleDataFromFile(filePath,fileName,separator=",",interactive=FALSE) -\end{Sinput} -\end{Schunk} - -\FloatBarrier -%------------------------------------------------------------ -\subsection{Merge Report} -%------------------------------------------------------------ -Finally, there is a function called mergeReport that will look at both the Daily and Sample dataframe, and populate Q and LogQ columns into the Sample dataframe. The default arguments are Daily and Sample, however if you want to use other similarly structured dataframes, you can specify localDaily or localSample. Once mergeReport has been run, the Sample dataframe will be augumented with the daily discharges for all the days with samples. None of the water quality functions in EGRET will work without first having run the mergeReport function. - - -\begin{Schunk} -\begin{Sinput} -> siteNumber <- "01491000" -> parameterCd <- "00631" # Nitrate -> startDate <- "2000-01-01" -> endDate <- "2013-01-01" -> Daily <- getDVData(siteNumber, "00060", startDate, endDate,interactive=FALSE) -> Sample <- getSampleData(siteNumber,parameterCd, startDate, endDate, interactive=FALSE) -> Sample <- mergeReport() -\end{Sinput} -\begin{Soutput} - Discharge Record is 4750 days long, which is 13 years - First day of the discharge record is 2000-01-01 and last day is 2013-01-01 - The water quality record has 220 samples - The first sample is from 2000-01-04 and the last sample is from 2012-12-18 - Discharge: Minimum, mean and maximum 0.00991 4.55 246 - Concentration: Minimum, mean and maximum 0.2 1.3 2.4 - Percentage of the sample values that are censored is 0 % -\end{Soutput} -\begin{Sinput} -> head(Sample) -\end{Sinput} -\begin{Soutput} - Date ConcLow ConcHigh Uncen ConcAve Julian Month Day DecYear MonthSeq -1 2000-01-04 1.59 1.59 1 1.59 54789 1 4 2000.010 1801 -2 2000-02-03 1.54 1.54 1 1.54 54819 2 34 2000.092 1802 -3 2000-02-15 1.37 1.37 1 1.37 54831 2 46 2000.124 1802 -4 2000-02-19 1.24 1.24 1 1.24 54835 2 50 2000.135 1802 -5 2000-03-23 0.52 0.52 1 0.52 54868 3 83 2000.225 1803 -6 2000-06-05 1.11 1.11 1 1.11 54942 6 157 2000.428 1806 - SinDY CosDY Q LogQ -1 0.06004896 0.9981954 2.746734 1.0104126 -2 0.54391895 0.8391378 3.936042 1.3701756 -3 0.70406552 0.7101350 10.845352 2.3837366 -4 0.75113193 0.6601521 15.517632 2.7419769 -5 0.98808790 0.1538906 56.916861 4.0415916 -6 0.43939951 -0.8982918 1.812278 0.5945847 -\end{Soutput} -\end{Schunk} - -\FloatBarrier -%------------------------------------------------------------ -\subsection{EGRET Plots} -%------------------------------------------------------------ -As has been mentioned, the data is specifically formatted to be used with the EGRET package. The EGRET package has powerful modeling capabilities using WRTDS, but also has a variety of graphing and tablular tools to explore the data without using the WRTDS algorithm. See the EGRET vignette, user guide, and/or wiki (\url{https://github.com/USGS-R/EGRET/wiki}) for detailed information. The following figure is an example of one of the plotting functions that can be used directly from the dataRetrieval dataframes. - -\begin{Schunk} -\begin{Sinput} -> # Continuing Choptank example from the previous sections -> library(EGRET) -> multiPlotDataOverview() -\end{Sinput} -\end{Schunk} - -\begin{figure}[ht] -\begin{center} - -\includegraphics{dataRetrieval-figegretEx} -\end{center} -\caption{Default multiPlotDataOverview} -\label{fig:multiPlotDataOverview} -\end{figure} - -\clearpage -\appendix -%------------------------------------------------------------ -\section{Getting Started in R} -\label{sec:appendix1} -%------------------------------------------------------------ -This section describes the options for downloading and installing the dataRetrieval package. - -%------------------------------------------------------------ -\subsection{New to R?} -%------------------------------------------------------------ -If you are new to R, you will need to first install the latest version of R, which can be found here: \url{http://www.r-project.org/}. - -There are many options for running and editing R code, one nice environment to learn R is RStudio. RStudio can be downloaded here: \url{http://rstudio.org/}. Once R and RStudio are installed, the dataRetrieval package needs to be installed as described in the next section. - -At any time, you can get information about any function in R by typing a question mark before the functions name. This will open a file (in RStudio, in the Help window) that describes the function, the required arguments, and provides working examples. - -\begin{Schunk} -\begin{Sinput} -> ?removeDuplicates -\end{Sinput} -\end{Schunk} - -To see the raw code for a particular code, type the name of the function: -\begin{Schunk} -\begin{Sinput} -> removeDuplicates -\end{Sinput} -\begin{Soutput} -function (localSample = Sample) -{ - Sample1 <- localSample[!duplicated(localSample[c("DecYear", - "ConcHigh")]), ] - return(Sample1) -} -<environment: namespace:dataRetrieval> -\end{Soutput} -\end{Schunk} - - -%------------------------------------------------------------ -\subsection{R User: Installing dataRetrieval} -%------------------------------------------------------------ -Before installing dataRetrieval, the zoo packages must be installed from CRAN: - -\begin{Schunk} -\begin{Sinput} -> install.packages("zoo") -> install.packages("dataRetrieval", repos="http://usgs-r.github.com", type="source") -\end{Sinput} -\end{Schunk} - -It is a good idea to re-start the R enviornment after installing the package, especially if installing an updated version. Some users have found it necessary to delete the previous version's package folder before installing newer version of dataRetrieval. If you are experiencing issues after updating a package, trying deleting the package folder - the default location for Windows is something like this: C:/Users/userA/Documents/R/win-library/2.15/dataRetrieval, and the default for a Mac: /Users/userA/Library/R/2.15/library/dataRetrieval. Then, re-install the package using the directions above. Moving to CRAN should solve this problem. - -After installing the package, you need to open the library each time you re-start R. This is done with the simple command: -\begin{Schunk} -\begin{Sinput} -> library(dataRetrieval) -\end{Sinput} -\end{Schunk} -Using RStudio, you could alternatively click on the checkbox for dataRetrieval in the Packages window. - -%------------------------------------------------------------ -\subsection{R Developers: Installing dataRetrieval from gitHub} -%------------------------------------------------------------ -Alternatively, R-developers can install the latest working version of dataRetrieval directly from gitHub using the devtools package (available on CRAN). Rtools (for Windows) and appropriate \LaTeX\ tools are required. Be aware that the version installed using this method isn't necessarily the same as the version in the stable release branch. - - -\begin{Schunk} -\begin{Sinput} -> library(devtools) -> install_github("dataRetrieval", "USGS-R") -\end{Sinput} -\end{Schunk} -To then open the library, simply type: - -\begin{Schunk} -\begin{Sinput} -> library(dataRetrieval) -\end{Sinput} -\end{Schunk} - -%------------------------------------------------------------ -\section{Columns Names} -\label{sec:appendix2} -%------------------------------------------------------------ - -%------------------------------------------------------------ -\subsection{INFO dataframe} -\label{sec:appendix2INFO} -%------------------------------------------------------------ - -% latex table generated in R 3.0.0 by xtable 1.7-1 package -% Mon Apr 08 10:10:02 2013 -\begin{tabular}{l} - \hline - \hline -agency.cd \\ - site.no \\ - station.nm \\ - site.tp.cd \\ - lat.va \\ - long.va \\ - dec.lat.va \\ - dec.long.va \\ - coord.meth.cd \\ - coord.acy.cd \\ - coord.datum.cd \\ - dec.coord.datum.cd \\ - district.cd \\ - state.cd \\ - county.cd \\ - country.cd \\ - map.nm \\ - map.scale.fc \\ - alt.va \\ - alt.meth.cd \\ - alt.acy.va \\ - alt.datum.cd \\ - huc.cd \\ - basin.cd \\ - topo.cd \\ - construction.dt \\ - inventory.dt \\ - drain.area.va \\ - contrib.drain.area.va \\ - tz.cd \\ - local.time.fg \\ - reliability.cd \\ - project.no \\ - queryTime \\ - drainSqKm \\ - shortName \\ - staAbbrev \\ - param.nm \\ - param.units \\ - paramShortName \\ - paramNumber \\ - constitAbbrev \\ - \hline -\end{tabular} -\FloatBarrier - -%------------------------------------------------------------ -\subsection{Water Quality Portal} -\label{sec:appendix2WQP} -%------------------------------------------------------------ - -There are 62 columns returned from the water quality portal. - -% latex table generated in R 3.0.0 by xtable 1.7-1 package -% Mon Apr 08 10:10:02 2013 -\begin{tabular}{l} - \hline - \hline -OrganizationIdentifier \\ - OrganizationFormalName \\ - ActivityIdentifier \\ - ActivityTypeCode \\ - ActivityMediaName \\ - ActivityMediaSubdivisionName \\ - ActivityStartDate \\ - ActivityStartTime.Time \\ - ActivityStartTime.TimeZoneCode \\ - ActivityEndDate \\ - ActivityEndTime.Time \\ - ActivityEndTime.TimeZoneCode \\ - ActivityDepthHeightMeasure.MeasureValue \\ - ActivityDepthHeightMeasure.MeasureUnitCode \\ - ActivityDepthAltitudeReferencePointText \\ - ActivityTopDepthHeightMeasure.MeasureValue \\ - ActivityTopDepthHeightMeasure.MeasureUnitCode \\ - ActivityBottomDepthHeightMeasure.MeasureValue \\ - ActivityBottomDepthHeightMeasure.MeasureUnitCode \\ - ProjectIdentifier \\ - ActivityConductingOrganizationText \\ - MonitoringLocationIdentifier \\ - ActivityCommentText \\ - SampleAquifer \\ - HydrologicCondition \\ - HydrologicEvent \\ - SampleCollectionMethod.MethodIdentifier \\ - SampleCollectionMethod.MethodIdentifierContext \\ - SampleCollectionMethod.MethodName \\ - SampleCollectionEquipmentName \\ - ResultDetectionConditionText \\ - CharacteristicName \\ - ResultSampleFractionText \\ - ResultMeasureValue \\ - ResultMeasure.MeasureUnitCode \\ - MeasureQualifierCode \\ - ResultStatusIdentifier \\ - StatisticalBaseCode \\ - ResultValueTypeName \\ - ResultWeightBasisText \\ - \hline -\end{tabular} -\FloatBarrier - -% latex table generated in R 3.0.0 by xtable 1.7-1 package -% Mon Apr 08 10:10:02 2013 -\begin{tabular}{l} - \hline - \hline -ResultTimeBasisText \\ - ResultTemperatureBasisText \\ - ResultParticleSizeBasisText \\ - PrecisionValue \\ - ResultCommentText \\ - USGSPCode \\ - ResultDepthHeightMeasure.MeasureValue \\ - ResultDepthHeightMeasure.MeasureUnitCode \\ - ResultDepthAltitudeReferencePointText \\ - SubjectTaxonomicName \\ - SampleTissueAnatomyName \\ - ResultAnalyticalMethod.MethodIdentifier \\ - ResultAnalyticalMethod.MethodIdentifierContext \\ - ResultAnalyticalMethod.MethodName \\ - MethodDescriptionText \\ - LaboratoryName \\ - AnalysisStartDate \\ - ResultLaboratoryCommentText \\ - DetectionQuantitationLimitTypeName \\ - DetectionQuantitationLimitMeasure.MeasureValue \\ - DetectionQuantitationLimitMeasure.MeasureUnitCode \\ - PreparationStartDate \\ - \hline -\end{tabular} -\clearpage - -%------------------------------------------------------------ -\section{Creating tables in Microsoft from R} -\label{app:createWordTable} -%------------------------------------------------------------ -There are a few steps that are required in order to create a table in a Microsoft product (Excel, Word, Powerpoint, etc.) from an R dataframe. There are certainly a variety of good methods, one of which is detailed here. The example we will step through here will be to create a table in Microsoft Word based on the dataframe tableData: - -\begin{Schunk} -\begin{Sinput} -> ChoptankAvailableData <- getDataAvailability(siteNumber) -> ChoptankDailyData <- ChoptankAvailableData["dv" == ChoptankAvailableData$service,] -> ChoptankDailyData <- ChoptankDailyData["00003" == ChoptankDailyData$statCd,] -> pCodeINFO <- getMultipleParameterNames(ChoptankDailyData$parameter_cd, interactive=FALSE) -> ChoptankDailyData <- merge(ChoptankDailyData,pCodeINFO,by="parameter_cd") -> tableData <- with(ChoptankDailyData, - data.frame( - shortName=srsname, - Start=startDate, - End=endDate, - Count=count, - Units=parameter_units) - ) -\end{Sinput} -\end{Schunk} - -First, save the dataframe as a tab delimited file (you don't want to use comma delimited because there are commas in some of the data elements): - - -\begin{Schunk} -\begin{Sinput} -> write.table(tableData, file="tableData.tsv",sep="\t", - row.names = FALSE,quote=FALSE) -\end{Sinput} -\end{Schunk} - -This will save a file in your working directory called tableData.tsv. You can see your working directory by typing getwd() in the R console. Opening the file in a general-purpose text editor, you should see the following: - -\begin{verbatim} -shortName Start End Count Units -Temperature, water 2010-10-01 2012-06-24 575 deg C -Stream flow, mean. daily 1948-01-01 2013-03-13 23814 cfs -Specific conductance 2010-10-01 2012-06-24 551 uS/cm @25C -Suspended sediment concentration (SSC) 1980-10-01 1991-09-30 3651 mg/l -Suspended sediment discharge 1980-10-01 1991-09-30 3652 tons/day -\end{verbatim} - -To open this file in Excel: -\begin{enumerate} -\item Open Excel -\item Click on the File tab -\item Click on the Open option -\item Browse to the working directory (as shown in the results of getwd()) -\item Next to the File name text box, change the dropdown type to All Files (*.*) -\item Double click tableData.tsv -\item A text import wizard will open up, in the first window, choose the Delimited radio button if it is not automatically picked, then click on Next. -\item In the second window, click on the Tab delimiter if it is not automatically checked, then click Finished. -\item Use the many formatting tools within Excel to customize the table -\end{enumerate} - -From Excel, it is simple to copy and paste the tables in other Microsoft products. An example using one of the default Excel table formats is here. - -\begin{figure}[ht!] -\centering - \resizebox{0.9\textwidth}{!}{\includegraphics{table1.png}} -\caption{A simple table produced in Microsoft Excel} -\label{overflow} -\end{figure} - -\clearpage -%------------------------------------------------------------ -% BIBLIO -%------------------------------------------------------------ -\begin{thebibliography}{10} - -\bibitem{HirschI} -Helsel, D.R. and R. M. Hirsch, 2002. Statistical Methods in Water Resources Techniques of Water Resources Investigations, Book 4, chapter A3. U.S. Geological Survey. 522 pages. \url{http://pubs.usgs.gov/twri/twri4a3/} - -\bibitem{HirschII} -Hirsch, R. M., Moyer, D. L. and Archfield, S. A. (2010), Weighted Regressions on Time, Discharge, and Season (WRTDS), with an Application to Chesapeake Bay River Inputs. JAWRA Journal of the American Water Resources Association, 46: 857-880. doi: 10.1111/j.1752-1688.2010.00482.x \url{http://onlinelibrary.wiley.com/doi/10.1111/j.1752-1688.2010.00482.x/full} - -\bibitem{HirschIII} -Sprague, L. A., Hirsch, R. M., and Aulenbach, B. T. (2011), Nitrate in the Mississippi River and Its Tributaries, 1980 to 2008: Are We Making Progress? Environmental Science \& Technology, 45 (17): 7209-7216. doi: 10.1021/es201221s \url{http://pubs.acs.org/doi/abs/10.1021/es201221s} - -\end{thebibliography} - -\end{document} - -\end{document} diff --git a/inst/doc/dataRetrieval.toc b/inst/doc/dataRetrieval.toc deleted file mode 100644 index f05553d7aa44793f0a9945381c7f4fe909a895f7..0000000000000000000000000000000000000000 --- a/inst/doc/dataRetrieval.toc +++ /dev/null @@ -1,31 +0,0 @@ -\select@language {american} -\contentsline {section}{\numberline {1}Introduction to dataRetrieval}{2}{section.1} -\contentsline {section}{\numberline {2}General USGS Web Retrievals}{3}{section.2} -\contentsline {subsection}{\numberline {2.1}Introduction}{3}{subsection.2.1} -\contentsline {subsection}{\numberline {2.2}Site Information}{4}{subsection.2.2} -\contentsline {subsubsection}{\numberline {2.2.1}getSiteFileData}{4}{subsubsection.2.2.1} -\contentsline {subsubsection}{\numberline {2.2.2}getDataAvailability}{5}{subsubsection.2.2.2} -\contentsline {subsection}{\numberline {2.3}Parameter Information}{6}{subsection.2.3} -\contentsline {subsection}{\numberline {2.4}Daily Values}{7}{subsection.2.4} -\contentsline {subsection}{\numberline {2.5}Unit Values}{8}{subsection.2.5} -\contentsline {subsection}{\numberline {2.6}Water Quality Values}{10}{subsection.2.6} -\contentsline {subsection}{\numberline {2.7}STORET Water Quality Retrievals}{11}{subsection.2.7} -\contentsline {subsection}{\numberline {2.8}URL Construction}{12}{subsection.2.8} -\contentsline {section}{\numberline {3}Data Retrievals Structured For Use In The EGRET Package}{12}{section.3} -\contentsline {subsection}{\numberline {3.1}INFO Data}{13}{subsection.3.1} -\contentsline {subsection}{\numberline {3.2}Daily Data}{13}{subsection.3.2} -\contentsline {subsection}{\numberline {3.3}Sample Data}{14}{subsection.3.3} -\contentsline {subsection}{\numberline {3.4}Censored Values: Summation Explanation}{15}{subsection.3.4} -\contentsline {subsection}{\numberline {3.5}User-Generated Data Files}{16}{subsection.3.5} -\contentsline {subsubsection}{\numberline {3.5.1}getDailyDataFromFile}{16}{subsubsection.3.5.1} -\contentsline {subsubsection}{\numberline {3.5.2}getSampleDataFromFile}{17}{subsubsection.3.5.2} -\contentsline {subsection}{\numberline {3.6}Merge Report}{18}{subsection.3.6} -\contentsline {subsection}{\numberline {3.7}EGRET Plots}{19}{subsection.3.7} -\contentsline {section}{\numberline {A}Getting Started in R}{21}{appendix.A} -\contentsline {subsection}{\numberline {A.1}New to R?}{21}{subsection.A.1} -\contentsline {subsection}{\numberline {A.2}R User: Installing dataRetrieval}{21}{subsection.A.2} -\contentsline {subsection}{\numberline {A.3}R Developers: Installing dataRetrieval from gitHub}{22}{subsection.A.3} -\contentsline {section}{\numberline {B}Columns Names}{24}{appendix.B} -\contentsline {subsection}{\numberline {B.1}INFO dataframe}{24}{subsection.B.1} -\contentsline {subsection}{\numberline {B.2}Water Quality Portal}{25}{subsection.B.2} -\contentsline {section}{\numberline {C}Creating tables in Microsoft from R}{27}{appendix.C} diff --git a/inst/doc/table1.png b/inst/doc/table1.png deleted file mode 100644 index 7749eaea99398767a012bccae4508e94e49362e7..0000000000000000000000000000000000000000 Binary files a/inst/doc/table1.png and /dev/null differ