subset                 package:base                 R Documentation

_S_u_b_s_e_t_t_i_n_g _V_e_c_t_o_r_s _a_n_d _D_a_t_a _F_r_a_m_e_s

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

     Return subsets of vectors or data frames which meet conditions.

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

     subset(x, ...)
     subset.default(x, subset)
     subset.data.frame(x, subset, select)

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

       x: object to be subsetted

     ...: how to subset, depends on object

  subset: logical expression

  select: expression, indicating variables to select from a data frame

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

     For ordinary vectors, the result is simply `x[subset &
     !is.na(subset)]'.

     For dataframes, the `subset' argument works similarly on the rows.
      Note that `subset' will be evaluated in the dataframe.

     The `select' argument exists only for dataframes.  It works by
     first replacing variable names in the selection expression with
     the corresponding column numbers in the dataframe and then using
     the resulting integer vector to index the columns.  This allows
     the use of the standard indexing conventions so that for examples
     ranges of variables can be specified easily.

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

     Selected rows and columns of the object `x'.

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

     Peter Dalgaard

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

     `[',  `transform'

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

     data(airquality)
     subset(airquality, Temp > 80, select = c(Ozone, Temp))
     subset(airquality, Day == 1, select = -Temp)
     subset(airquality, select = Ozone:Wind)

     attach(airquality)
     subset(Ozone, Temp > 80)

