mksub                  package:seas                  R Documentation

_M_a_k_e _a _s_u_b_s_e_t _o_f _s_e_a_s_o_n_a_l _d_a_t_a

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

     Creates a subset of a 'data.frame' with temporal observations,
     using IDs and start and ending dates or years.

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

       mksub(x, start, end, id)

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

       x: a data frame with temporal observations

   start: either a starting 'Date' or 'integer' year; if omitted
          minimum will be used

     end: either an ending 'Date' or year; if omitted will use same
          year as 'start', and if 'start' is omitted, will use maximum
          year

      id: unique station identifier (if present), which is assumed to
          be a column of 'x' as 'x$id'; it is used to extract a subset
          of data from a single ID

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

     This utility function is useful for creating temporal subsets of
     seasonal data and for extracting a single station out of a
     'data.frame' with multiple stations or sets. The 'x' object can
     have many columns, representing measured variables for each day,
     which will be returned with their original attributes.

     If 'id' is used, that station will be extracted from 'x'. If 'id'
     is not provided, but there are more than one unique IDs in 'x$id',
     the first unique ID will be extracted, with a warning.

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

     Returns a subset of a 'data.frame' with the same columns and
     attributes as 'x', except 'id', which will be retained as an
     attribute (e.g., 'attr(x,"id")').

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

     M.W. Toews

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

     'read.msc', 'mscdata'

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

     data(mscstn)
     data(mscdata)

     # All available data from one station
     summary(mksub(mscdata, id=1108447))

     # One year
     str(mksub(mscdata, id=1108447, start=1980))

     # A range of years
     str(mksub(mscdata, id=1108447, start=1980, end=1989))

     # A range of dates
     summary(mksub(mscdata, id=1108447,
                   start=as.Date("1975-08-01"),
                     end=as.Date("2000-07-31")))

