TRAMPindexing             package:TRAMPR             R Documentation

_I_n_d_e_x (_S_u_b_s_e_t) _T_R_A_M_P_s_a_m_p_l_e_s _a_n_d _T_R_A_M_P_k_n_o_w_n_s _O_b_j_e_c_t_s

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

     This provides very basic support for subsetting 'TRAMPsamples' and
     'TRAMPknowns' objects.

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

     x[i, na.interp=TRUE, ...]

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

       x: A 'TRAMPsamples' or 'TRAMPknowns' object.

       i: A vector of 'sample.fk' or 'knowns.fk' values.  For valid
          values, use 'labels(x)'.  If any index values are not present
          in 'x', then an error will be raised.  Alternatively, this
          may be a logical vector, of the same length as the number of
          samples or knowns in 'x'.  See Examples for use of this. 

na.interp: Logical: Controls how 'NA' values should be interpreted when
          'i' is a logical vector.

     ...: Further arguments passed to or from other methods.

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

     When indexing by logical vectors, 'NA' values do not make valid
     indexes, but may be produced when testing columns that contain
     missing values, so these must be converted to either 'TRUE' or
     'FALSE'. If 'i' is a logical index that contains missing values
     ('NA's), then 'na.interp' controls how they will be interpreted:

        *  If 'na.interp=TRUE', then 'TRUE, FALSE, NA' becomes 'TRUE,
           FALSE, TRUE'.

        *  If 'na.interp=FALSE', then 'TRUE, FALSE, NA' becomes 'TRUE,
           FALSE, FALSE'.

_W_a_r_n_i_n_g:

     For 'TRAMPknowns' objects, if the 'file.pat' element is specified
     as part of the object (see 'TRAMPknowns'), then the subsetted
     'TRAMPknowns' object will be written to a file. This may not be
     what you want, so it is probably best to disable knowns writing by
     doing 'x$file.pat <- NULL' before doing any subsetting (where 'x'
     is the name of your 'TRAMPknowns' object).

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

     data(demo.samples)
     data(demo.knowns)

     ## Subsetting by sample.fk values
     labels(demo.samples)
     demo.samples[c(101, 102, 110)]
     labels(demo.samples[c(101, 102, 110)])

     ## Take just samples from the first 10 soilcores:
     demo.samples[demo.samples$info$soilcore.fk <= 10]

     ## Indexing also works on TRAMPknowns:
     demo.knowns[733]
     labels(demo.knowns[733])

