expand                package:epicalc                R Documentation

_E_x_p_a_n_d _a_n _a_g_g_r_e_g_a_t_e_d _d_a_t_a _f_r_a_m_e

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

     Expand an 'aggregate'd data frame into a case-by-case format based
     on the values specified in a column

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

     expand(aggregate.data, index.var = "Freq", retain.freq = FALSE)

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

aggregate.data: an aggregate data frame having a variable indicating
          the replication of subjects having that combination of
          characteristics, which are indicated by other variables

index.var: name of a variable indicating frequency of replication

retain.freq: whether the index variable or frequency variable should be
          retained in the return data frame

_D_e_t_a_i_l_s:

     An aggregated data frame has one variable (colunm) indicating the
     number or frequency of replication of subjects having the same
     values of other variables as the index record.

     'expand' replicates the row using the value in 'index.var' as the
     number of replications.

     'retain.freq' indicates whether the 'index.var', which is the
     frequency, should be retained.

_N_o_t_e:

     The aggregated data frame is not changed. Remember to assign the
     result

_A_u_t_h_o_r(_s):

     Virasakdi Chongsuvivatwong <cvirasak@medicine.psu.ac.th>

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

     'table', 'xtabs', 'aggregate'

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

     ## Expanding an aggregate data frame
     data(ANCtable)
     des(ANCtable)
     a <- expand(ANCtable)
     des(a)

     ## Aggregating a case-by-case data frame
     data(ANCdata)
     use(ANCdata)
     des()
     id <- 1:nrow(ANCdata)
     aggregate.numeric(id, by=list(Death=death, Anc=anc, Clinic=clinic), 
             FUN="count")

