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)

