codebook               package:memisc               R Documentation

_G_e_n_e_r_a_t_e _a _C_o_d_e_b_o_o_k _o_f _a _D_a_t_a _S_e_t

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

     Function 'codebook' collects documentation about an item, or the
     items in a data set or external data file. It returns an object
     that, when 'show'n, print this documentation in a nicely formatted
     way.

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

     codebook(x)
     ## S4 method for signature 'data.set':
     codebook(x)
     ## S4 method for signature 'importer':
     codebook(x)

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

       x: an 'item',  'data.set' or 'importer' object.

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

     An object of class "codebook", for which a 'show' method exists
     that produces a nicely formatted output.

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

     Data <- data.set(
               vote = sample(c(1,2,3,8,9,97,99),size=300,replace=TRUE),
               region = sample(c(rep(1,3),rep(2,2),3,99),size=300,replace=TRUE),
               income = exp(rnorm(300,sd=.7))*2000
               )

     Data <- within(Data,{
       description(vote) <- "Vote intention"
       description(region) <- "Region of residence"
       description(income) <- "Household income"
       wording(vote) <- "If a general election would take place next tuesday,
                         the candidate of which party would you vote for?"
       wording(income) <- "All things taken into account, how much do all
                         household members earn in sum?"
       foreach(x=c(vote,region),{
         measurement(x) <- "nominal"
         })
       measurement(income) <- "ratio"
       labels(vote) <- c(
                         Conservatives         =  1,
                         Labour                =  2,
                         "Liberal Democrats"   =  3,
                         "Don't know"          =  8,
                         "Answer refused"      =  9,
                         "Not applicable"      = 97,
                         "Not asked in survey" = 99)
       labels(region) <- c(
                         England               =  1,
                         Scotland              =  2,
                         Wales                 =  3,
                         "Not applicable"      = 97,
                         "Not asked in survey" = 99)
       foreach(x=c(vote,region,income),{
         annotation(x)["Remark"] <- "This is not a real survey item, of course ..."
         })
       missing.values(vote) <- c(8,9,97,99)
       missing.values(region) <- c(97,99)
     })

     codebook(Data)

