| sqlsurvey {surveyNG} | R Documentation |
Specifies a survey data set based on a connection to a SQL (currently SQLite) database. The data may be in an existing database or in a data frame that will be written out to a database. If data are in an existing database they should be in a single table in denormalized form.
sqlsurvey(id, strata = NULL, weights = NULL, fpc = "0", data,
table.name = basename(tempfile("_tbl_")), key = "row_names")
## S3 method for class 'sqlsurvey':
close(con, tidy=TRUE, ...)
## S3 method for class 'sqlsurvey':
open(con, db=NULL,...)
## S3 method for class 'sqlmodelmatrix':
open(con, design,...)
id |
vector of strings with names of sampling unit identifiers |
strata |
vector of strings with names of stratum identifies |
weights |
string with name of weighting variable |
fpc |
string with name of population size variable (variable may be zero for sampling with replacement or infinite population size) |
data |
Either a data frame or the name of a SQLite database file |
table.name |
Name for the data table containing the survey data and design variables |
key |
name of a variable that can be used as a unique key |
con |
survey object or survey model matrix object to be disconnected from or reconnected to the database |
tidy |
Clear any pending results? |
db |
An existing connection (optional, allows multiple objects to be reconnected to the same database connection) |
design |
A sqlsurvey object with an active database
connection |
... |
For future expansion |
sqlsurvey returns an object of class sqlsurvey
library(survey)
data(api)
sqclus2<-sqlsurvey(id=c("dnum","snum"), fpc=c("fpc1","fpc2"),
weights="pw", data=apiclus2)
sqclus2
svymean(~api99+api00, design=sqclus2)
sqclus1<-sqlsurvey(id="dnum", fpc="fpc", weights="pw", strata="fpc",
data=system.file("apiclus1.db",package="surveyNG"),
table.name="clus1", key="snum")
sqclus1
svymean(~api99+api00, design=sqclus1)
close(sqclus1)
close(sqclus2)