sqlsurvey              package:surveyNG              R Documentation

_S_u_r_v_e_y _d_e_s_i_g_n _b_a_s_e_d _o_n _S_Q_L _d_a_t_a_b_a_s_e

_D_e_s_c_r_i_p_t_i_o_n:

     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.

_U_s_a_g_e:

     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,...)

_A_r_g_u_m_e_n_t_s:

      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

_V_a_l_u_e:

     'sqlsurvey' returns an object of class 'sqlsurvey'

_S_e_e _A_l_s_o:

_E_x_a_m_p_l_e_s:

     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)

