Skip to content

Instantly share code, notes, and snippets.

@hannes
Created June 29, 2016 18:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hannes/f6d590b4efcda539d0e8a27c420764dc to your computer and use it in GitHub Desktop.
Save hannes/f6d590b4efcda539d0e8a27c420764dc to your computer and use it in GitHub Desktop.
# 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