sqlmodelmatrix {surveyNG} | R Documentation |
Given a formula and a sqlsurvey
design object, create SQL
tables with a model frame and model matrix.
sqlmodelmatrix(formula, design, fullrank = TRUE)
formula |
model formula |
design |
sqlsurvey object |
fullrank |
if FALSE return a matrix of indicators for any
factor variables, not a full-rank design matrix |
Currently, no transformations are allowed in the formula, factors will be coded with treatment contrasts, and interactions are allowed only between factor variables.
The database tables created by this function will be removed if the R object is deleted and garbage collected.
An object of class sqlmodelmatrix
link{open.sqlmodelmatrix}
for reconnecting saved objects
sqclus1<-sqlsurvey(id="dnum", fpc="fpc", weights="pw", strata="fpc", data=system.file("apiclus1.db",package="surveyNG"), table.name="clus1", key="snum") mm <- sqlmodelmatrix(api00~stype*comp_imp+ell+api99, sqclus1) dbGetQuery(sqclus1$conn, sqlsubst("select * from %%mm%% limit 2", list(mm=mm$table))) dbListTables(sqclus1$conn) rm(mm) gc() dbListTables(sqclus1$conn) close(sqclus1)