By                  package:memisc                  R Documentation

_C_o_n_d_i_t_i_o_n_a_l _e_v_a_l_u_a_t_i_o_n _o_f _a_n _e_x_p_r_e_s_s_i_o_n

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

     The function 'By' evaluates an expression within subsets of a data
     frame, where the subsets are defined by a formula.

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

     By(formula,expr,data=parent.frame())

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

 formula: an expression or (preferably) a formula containing the names
          of conditioning variables or factors.

    expr: an expression that is evaluated for any unique combination of
          values of the variables contained in 'formula'.

    data: a data frame, an object that can be coerced into a data frame
          (for example, a table), or an environment, from which values
          for the variables in 'formula' or 'expr' are taken. 

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

     A list of class "by", giving the results for each combination of
     values of variables in 'formula'.

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

     berkeley <- aggregate(Table(Admit,Freq)~.,data=UCBAdmissions)
     By(~Dept,glm(cbind(Admitted,Rejected)~Gender,family="binomial"),data=berkeley)

     attach(berkeley)
     By(~Dept,glm(cbind(Admitted,Rejected)~Gender,family="binomial"))
     detach(berkeley)

