matchcols               package:gdata               R Documentation

_S_e_l_e_c_t _c_o_l_u_m_n_s _n_a_m_e_s _m_a_t_c_h_i_n_g _c_e_r_t_a_i_n _c_r_i_t_e_r_a

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

     This function allows easy selection of the column names of an
     object using a set of inclusion and exclusion critera.

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

     matchcols(object, with, without, method=c("and","or"), ...)

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

  object: Matrix or dataframe

with, without: Vector of regular expression patterns

  method: One of "and" or "or"

     ...: Optional arguments to 'grep'

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

     Vector of column names which match all ('method="and"') or any
     ('method="or"') of the patterns specified in 'with', but none of
     the patterns specified in 'without'.

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

     Gregory R. Warnes warnes@bst.rochester.edu

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

     'grep'

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

     # create a matrix with a lot of named columns
     x <- matrix( ncol=30, nrow=5 )
     colnames(x) <- c("AffyID","Overall Group Means: Control",
                          "Overall Group Means: Moderate",
                          "Overall Group Means: Marked",
                          "Overall Group Means: Severe",
                          "Overall Group StdDev: Control",
                          "Overall Group StdDev: Moderate",
                          "Overall Group StdDev: Marked",
                          "Overall Group StdDev: Severe",
                          "Overall Group CV: Control",
                          "Overall Group CV: Moderate",
                          "Overall Group CV: Marked",
                          "Overall Group CV: Severe",
                          "Overall Model P-value",
                          "Overall Model: (Intercept): Estimate",
                          "Overall Model: Moderate: Estimate",
                          "Overall Model: Marked: Estimate",
                          "Overall Model: Severe: Estimate",
                          "Overall Model: (Intercept): Std. Error",
                          "Overall Model: Moderate: Std. Error",
                          "Overall Model: Marked: Std. Error",
                          "Overall Model: Severe: Std. Error",
                          "Overall Model: (Intercept): t value",
                          "Overall Model: Moderate: t value",
                          "Overall Model: Marked: t value",
                          "Overall Model: Severe: t value",
                          "Overall Model: (Intercept): Pr(>|t|)",
                          "Overall Model: Moderate: Pr(>|t|)",
                          "Overall Model: Marked: Pr(>|t|)",
                          "Overall Model: Severe: Pr(>|t|)")

     # Get the columns which give estimates or p-values
     # only for marked and severe groups
     matchcols(x, with=c("Pr", "Std. Error"),
                  without=c("Intercept","Moderate"),
                  method="or"
               )

     # Get just the column which give the p-value for the intercept
     matchcols(x, with=c("Intercept", "Pr") )
                          

