R: Working with Databases

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizards Guide to PHP by David Lash.
Advertisements

CE203 - Application Programming Autumn 2013CE203 Part 51 Part 5.
PHP and MySQL Database. Connecting to MySQL Note: you need to make sure that you have MySQL software properly installed on your computer before you attempt.
PHP (2) – Functions, Arrays, Databases, and sessions.
Using Objects and Properties
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
CSE S. Tanimoto Syntax and Types 1 Representation, Syntax, Paradigms, Types Representation Formal Syntax Paradigms Data Types Type Inference.
Website Development & Management PHP Odds & Ends Instructor: John Seydel, Ph.D. CIT Fall
Chapter 8: I/O Streams and Data Files. In this chapter, you will learn about: – I/O file stream objects and functions – Reading and writing character-based.
Creating Database Tables CS 320. Review: Levels of data models 1. Conceptual: describes WHAT data the system contains 2. Logical: describes HOW the database.
Attribute databases. GIS Definition Diagram Output Query Results.
ADVM420- Class #4 Web Design with PHP and MySQL Adding and Listing from a MySQL Database.
Session-01. Hibernate Framework ? Why we use Hibernate ?
Phil Brewster  One of the first steps – identify the proper data types  Decide how data (in columns) should be stored and used.
MySql In Action Step by step method to create your own database.
SJSU CS157B Dr. Lee1  2004 Jenny Mitchell Two Useful Tools You Can’t Live Without by Jenny Mitchell SJSU CS157B Section PHP and MySQL.
Programming Languages
Overview of SQL Server Alka Arora.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
SQL HW1 Turn in as a hardcopy at the start of next class period. You may work this assignment in groups.
Week Four CIT 354 Internet II. 2 Objectives Uploading Files to Your Web Site Establishing a Connection Creating a Database Table Common Programming Errors.
Internet Forms and Database Bob Kisel Amgraf, Inc.
Python MySQL Database Access
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Introduction to Computer Programming Using C Session 23 - Review.
Introduction to CS520/CS596_026 Lecture Two Gordon Tian Fall 2015.
Sumanth M Ganesh B CPSC 620.  SQL Injection attacks allow a malicious individual to execute arbitrary SQL code on your server  The attack could involve.
Capabilities of Software. Object Linking & Embedding (OLE) OLE allows information to be shared between different programs For example, a spreadsheet created.
1 CS 430 Database Theory Winter 2005 Lecture 14: Additional SQL Topics.
SQL ACTION QUERIES AND TRANSACTION CONTROL CS 260 Database Systems.
Database Access Using JDBC BCIS 3680 Enterprise Programming.
Data Model / Database Implementation (continued) Jeffery S. Horsburgh Hydroinformatics Fall 2014 This work was funded by National Science Foundation Grants.
1 CS 430 Database Theory Winter 2005 Lecture 11: SQL DDL.
Class 3Intro to Databases Class 4 Simple Example of a Database We’re going to build a simple example of a database, which will allow us to register users.
Working With Database Library And Helpers. Connecting to your Database First you need to set parameters in you database.php file residing in config folder.
Lecture 11 Introduction to R and Accessing USGS Data from Web Services Jeffery S. Horsburgh Hydroinformatics Fall 2013 This work was funded by National.
Hydroinformatics Lecture 15: HydroServer and HydroServer Lite The CUAHSI HIS is Supported by NSF Grant# EAR CUAHSI HIS Sharing hydrologic data.
Pinellas County Schools
Using Python to Retrieve Data from the CUAHSI HIS Web Services Jeffery S. Horsburgh Hydroinformatics Fall 2015 This work was funded by National Science.
Introduction to Data Manipulation, Analysis, and Visualization with R Patrick Grof-Tisza.
PDO Database Connections MIS 3501, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 3/8/2016.
Using Python to Retrieve Data from the CUAHSI HIS Web Services Jon Goodall Hydroinformatics Fall 2014 This work was funded by National Science Foundation.
Web Systems & Technologies
Creating Database Objects
Fundamental of Databases
PDO Database Connections
C LANGUAGE MULITPLE CHOICE QUESTION SET-2
Working in the Forms Developer Environment
SQL and SQL*Plus Interaction
R: Packages and Data Retrieval
R: Packages and Data Retrieval
Lecture 8 Database Implementation
Unix System Administration
Representation, Syntax, Paradigms, Types
R and MySQL Database Tutorial
Data Management Module: Concatenating, Stacking, Merging and Recoding
Impact of Climate Change on Water Resources
ISC440: Web Programming 2 Server-side Scripting PHP 3
Thank you Sponsors.
Representation, Syntax, Paradigms, Types
Representation, Syntax, Paradigms, Types
Tutorial 6 PHP & MySQL Li Xu
JAVA DATABaSE CONNECTIVITY
Representation, Syntax, Paradigms, Types
R Course 1st Lecture.
Creating Database Objects
Web Application Development Using PHP
Interactive Powerpoint
Presentation transcript:

R: Working with Databases Hydroinformatics – Fall 2015

Learning Objectives Install and load packages Use help() features, documentation, other code, and to determine syntax for unfamiliar functions Describe documentation techniques Use RMySQL to interact with existing databases, create new databases, and import data Describe and visualize data using R statistical and graphical functions

RMySQL Package https://github.com/rstats-db/rmysql How does this documentation style compare to the USGS dataRetrieval Package? to the WaterML package? What is most useful? What is the most confusing thing about using a new package? How do you communicate most effectively with new users? Is this important to you if you are not creating and publishing packages? Why or why not?

RMySQL Package Note: You need to actually set the password! dbDriver tells it which type of Database management system you are working with

Interacting with Your Database Try: Listing all available tables in the database Hint 1: Look up functions ls("package:RMySQL") Hint 2: Use help(“function_name”) to get arguments Try: Creating a new table in the LoganRiverODM Database This code was modified from the sql script that we used to create the tables in the LoganRiverODM database.

Interacting with Your Database What does the argument “n=-1” mean? No need to parse the data – the Fetch function puts the queried data directly into an R data.frame format! Note: What is the n=-1? (Look at the help(dbFetch) for more information on the syntax) No need to parse data – it automatically assigns column names

Important Notes MySQL tables are read into R as data.frames, but without coercing character or logical data into factors. Similarly while exporting data.frames, factors are exported as character vectors. Integer columns are usually imported as R integer vectors, except for cases such as BIGINT or UNSIGNED INTEGER which are coerced to R's double precision vectors to avoid truncation Time variables are imported/exported as character data, so you need to convert these to your favorite date/time representation. Additional Notes: Factors are a specific data type for categories or levels Integers in MySQL can be set as INT, BIGINT, UNSIGNED INTEGER, etc., but in R, it does not recognize these different data types. It will either recognize INT as integer, or BIGINT, etc., as a double. Need to convert the time variables

Creating and Loading Data for WEAP Model Hints: Look at the SQL scripts that you used to create the ODM and LoganRiverODM databases for the correct syntax for 2 and 3 1. #Set the driver and connection 2. #Create the database dbSendQuery() 3. #Tell the connection which database to use 4. #Set SQL Mode dbSendQuery(con,"SET SESSION sql_mode = `NO_AUTO_VALUE_ON_ZERO`;") 5. #Load the data downloaded from SNOTEL (This should be a few lines of code from your most recent assignment) 6. #Import the data into tables

Visualize and Describe your Data http://www.cyclismo.org/tutorial/R/intermediatePlotting.h tml http://www.harding.edu/fmccown/r/ http://www.rdatamining.com/examples/exploration Share your results on the class Google Doc (on canvas)