Presentation is loading. Please wait.

Presentation is loading. Please wait.

R: Packages and Data Retrieval

Similar presentations


Presentation on theme: "R: Packages and Data Retrieval"— Presentation transcript:

1 R: Packages and Data Retrieval
Hydroinformatics – Fall 2015

2 Learning Objectives Describe the difference between packages and libraries in R Install and load packages Use documentation and other resources to learn how to use unfamiliar packages Use data retrieval packages and web services to obtain hydrologic data

3 R Packages and Libraries
Package: R functions, data, and compiled code in a well- defined format. Library: The directory where packages are stored.  Implement many common data analysis and statistical procedures Provide excellent graphics functionality Serve as a starting point for many data analysis tasks A huge community of R developers exist – it’s likely that there’s an R package for many of the tasks you commonly do

4 USGS Data Retrieval Package for R
Collection of functions to help retrieve hydrologic and water quality data using web services: U.S. Geological Survey (USGS) using National Water Information System (NWIS) tools U.S. Environmental Protection Agency (EPA) Data access is through web services

5 Installing and loading Packages
library() #displays available packages Tools>Install Packages or install.packages(“package_name”) library(package_name) #loads package

6 Demo – dataRetrieval We want to automate the retrieval and import of data from a specific site into R using the dataRetrieval package. But how? Use the source, Luke!

7 Demo – dataRetrieval for Gage Height
Try: Retrieve USGS gage height data for any site in Utah for May What function should you use? This package is well documented and its examples are very useful for modifying/tailoring to specific needs. For example, this code uses “service” (look at the examples and see that it is “iv” for one readNWISdata() and it is “site” for another. What do these terms mean, and where can you find out about them?

8 Demo – dataRetrieval for Gage Height
How do you find the parameter code for gage height? Explore the github documentation: If you know a package can help you, but you don’t know how to use the functions, you may have to explore! Find examples that you can modify: Search the comments in the function code:

9 Demo – dataRetrieval for Gage Height
Find site code: #Then modify the other example code with your site ID and parameter code instGage <- readNWISdata(sites=" ", service="iv",parameterCd="00065", startDate=' T00:00Z',endDate=' T00:00Z') UT 00065 From the examples in the readNWISdata function

10 WaterML Package for R WaterML is a standard information model for the representation of water observations data, with the intent of allowing the exchange of such data sets across information systems.

11 WaterML Package for R Developed as part of a semester project from last year, Jiri and Bryn from BYU

12 WaterML Package for R retrieve and analyze data from HydroServers of multiple organizations that are listed in the CUAHSI Water Data Center catalog  great example of semester project

13 Demo - WaterML Try downloading two variables from Red Butte Creek, Logan River, or Provo River GAMUT sites and fit a regression model between the two datasets out.pdf


Download ppt "R: Packages and Data Retrieval"

Similar presentations


Ads by Google