# This is a real life data management example from the author's work.
# It is the very reason for the existence of aggregatedDB
#
# First we have to 'plug in' the data base ...
library(RSQLite)
if(!exists("drv"))
drv <- dbDriver("SQLite")
if(!exists("con"))
con <- dbConnect(drv, dbname = "~/forschung/pieb.db3")
# This is a 400 MB SQLite data base that contains
# several tables contructed from cumulated eurobarometer
# survey data files, spanning the period from 1973 to 2002.
poldisc.data <- aggregateDB(table(poldisc)~nation+eb+educrec+sex+age+year,
subset = educrec < 900 & sex < 900 & age < 900 & poldisc < 900,
connection=con,
allow.sql.eval=TRUE,
table="ebtrend",
names=c(educrec="education",sex="gender")
)
polint.poldisc.data <- aggregateDB(percent(polint)~poldisc,
subset=polint < 900 & poldisc < 900,
connection=con,
table=mergeSQL("political_interest","ebtrend",by=c("nation","eb","id")))
Run the code above in your browser using DataLab