to.data.frame             package:memisc             R Documentation

_C_o_n_v_e_r_t _a_n _A_r_r_a_y _i_n_t_o _a _D_a_t_a _F_r_a_m_e

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

     'to.data.frame' converts an array into a data frame, in such a way
     that a chosen dimensional extent forms variables in the data
     frame. The elements of the array must be either atomic, data
     frames with matching variables, or coercable into such data
     frames.

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

     to.data.frame(X,as.vars=1,name="Freq")

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

       X: an array.

 as.vars: a numeric value; indicates the dimensional extend which
          defines the variables. Takes effect only if 'X' is  an atomic
          array. If 'as.vars' equals zero, a new variable is created
          that contains the values of the array, that is,
          'to.data.frame' acts on the array 'X' like
          'as.data.frame(as.table(X))' 

    name: a character string; the name of the variable created if 'X'
          is an atomic array and 'as.vars' equals zero. 

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

     A data frame.

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

     berkeley <- aggregate(Table(Admit,Freq)~.,data=UCBAdmissions)
     berktest1 <- By(~Dept+Gender,
                     glm(cbind(Admitted,Rejected)~1,family="binomial"),
                     data=berkeley)
     berktest2 <- By(~Dept,
                     glm(cbind(Admitted,Rejected)~Gender,family="binomial"),
                     data=berkeley)
     Stest1 <- Lapply(berktest2,function(x)predict(x,,se.fit=TRUE)[c("fit","se.fit")])
     Stest2 <- Sapply(berktest2,function(x)coef(summary(x)))
     Stest2.1 <- Lapply(berktest1,function(x)predict(x,,se.fit=TRUE)[c("fit","se.fit")])
     to.data.frame(Stest1)
     to.data.frame(Stest2,as.vars=2)
     to.data.frame(Stest2.1)

