Created
July 4, 2011 05:28
-
-
Save lynaghk/1062939 to your computer and use it in GitHub Desktop.
R + Sqlite example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this first: | |
# | |
# install.packages(c('RSQLite.extfuns', 'ggplot2', 'maps')) | |
# | |
library(RSQLite) | |
library(ggplot2) | |
library(RSQLite.extfuns) | |
db = dbConnect( | |
dbDriver("SQLite") | |
, dbname = 'watershed_database.db' | |
, loadable.extensions = TRUE) | |
#dbGetQuery just returns a data frame | |
pods = dbGetQuery(db, " | |
SELECT category, subbasin_name, quantity, geox, geoy | |
FROM pods | |
WHERE lic_status = 'CURRENT' | |
AND quantity IS NOT NULL") | |
summary(pods$quantity) | |
ggplot(data=pods) + | |
geom_point(aes(x=geox | |
, y=geoy | |
, color=category | |
, size=quantity)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where can I find the data to create watershed_database.db ?