cols2Env             package:AnnBuilder             R Documentation

_C_r_e_a_t_e_s _a _e_n_v_i_r_o_n_m_e_n_t _o_b_j_e_c_t _u_s_i_n_g _d_a_t_a _f_r_o_m _t_w_o _c_o_l_u_m_n_s _o_f _a _m_a_t_r_i_x

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

     Given a matrix with two columns, this function creates an
     environment object with values in one of the specified columns as
     keys and those in the other column as values.

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

     cols2Env(cols, colNames, keyColName = colNames[1], sep)
     matchAll(cols, keyColName)
     matchOneRow(cols, keyColName, sep = ";")

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

    cols: 'cols' a matrix with two columns

colNames: 'colNames' a charcter string for the name of the column whose
          values will be used for the keys of the environment object to
          be created

keyColName: 'keyColName' a character string for the name of the column
          whose values will be the corresponding values for keys of the
          environment object to be created

     sep: 'sep' a character for the separaters used to separate entries
          that have multiple values

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

     The matrix or matrix convertable object passed to cols2Env must
     have two coloumns with one intented to be used as the key and the
     other be the value.

     Cells in either or both columns may have multiple values separated
     by a separator (e.g. "a;b", "1;2;3") making the mapping between
     keys and the corresponding values not a straitforward operation.
     cols2Env gets all the unique values from the key column by
     spliting them and maps values to each of them.

     'cols2Env' calls 'matchAll' that in turn calls 'matchOneRow' to
     first split entries and then map entries in the two coloumns on
     one to one bases. Unique keys in the column defined as the key
     column will be assigned a vector containing all the values
     corresponding the keys in the environment to return.

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

     This function returns an environment object with key and value
     pairs

_N_o_t_e:

     This function is part of the Bioconductor project at Dana-Farber
     Cancer Institute to provide Bioinformatics functionalities through
     R

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

     Jianhua Zhang

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

     'ABPkgBuilder'

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

     dataM <- matrix(c("a;b", "1;2;3", "a;b", "4;5", "c", "6;7", "b;a",
     "6;7;8"), ncol = 2, byrow = TRUE)

     temp <- cols2Env(dataM, c("key", "value"), keyColName = "key")

     dataM
     multiget(ls(temp), temp)

