Created
June 29, 2016 18:00
-
-
Save hannes/f6d590b4efcda539d0e8a27c420764dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# rm -r /tmp/hmda | |
install.packages("MonetDBLite") | |
library(DBI) | |
dbdir <- "/tmp/hmda" | |
con <- dbConnect(MonetDBLite::MonetDBLite(), dbdir) | |
# download at http://homepages.cwi.nl/~hannes/hmda.rds | |
dd <- readRDS("/tmp/hmda.rds") | |
str(dd) | |
system.time(dbWriteTable(con, "hmda_demo", dd)) | |
dbListTables(con) | |
system.time(print(dbGetQuery(con, "SELECT actiontype, propertytype, loanpurpose, COUNT(*) AS num_records FROM hmda_demo GROUP BY actiontype, propertytype, loanpurpose ORDER BY actiontype, propertytype, loanpurpose LIMIT 10"))) | |
system.time(dd2 <- dbReadTable(con, "hmda_demo")) | |
library(dplyr) | |
hmda_src <- MonetDBLite::src_monetdblite(dbdir) | |
hmda_src | |
hmda_tbl <- tbl(hmda_src, "hmda_demo") | |
hmda_tbl | |
hmda_tbl %>% group_by(actiontype, propertytype, loanpurpose) %>% summarise(num_records = n()) %>% arrange(actiontype, propertytype, loanpurpose) %>% head(10) | |
quit("no") | |
# R | |
library(DBI) | |
system.time(con <- dbConnect(MonetDBLite::MonetDBLite(), "/tmp/hmda")) | |
system.time(dd2 <- dbReadTable(con, "hmda_demo")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment