dbApply-methods            package:RMySQL            R Documentation

_A_p_p_l_y _R/_S-_P_l_u_s _f_u_n_c_t_i_o_n_s _t_o _r_e_m_o_t_e _g_r_o_u_p_s _o_f _D_B_M_S _r_o_w_s (_e_x_p_e_r_i_m_e_n_t_a_l)

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

     Applies R/S-Plus functions to groups of remote DBMS rows without
     bringing an entire result set all at once.  The result set is
     expected to be sorted by the grouping field.

_M_e_t_h_o_d_s:

     _r_e_s a MySQL result set (see 'dbSendQuery').

     ... any additional arguments to be passed to 'FUN'.

_R_e_f_e_r_e_n_c_e_s:

     See the Database Interface definition document 'DBI.pdf' in the
     base directory of this package or <URL:
     http://stat.bell-labs.com/RS-DBI>.

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

     'MySQL' 'mysqlDBApply' 'dbSendQuery' 'fetch'

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

     ## Not run: 
     ## compute quanitiles for each network agent
     con <- dbConnect(MySQL(), group="vitalAnalysis")
     rs <- dbSendQuery(con, 
                  "select Agent, ip_addr, DATA from pseudo_data order by Agent")
     out <- dbApply(rs, INDEX = "Agent", 
             FUN = function(x, grp) quantile(x$DATA, names=FALSE))
     ## End(Not run)

