Just like extraction and replacement with indexes in base R, but preserving the special attributes used in spectral classes and checking for validity of remaining spectral data.
# S3 method for generic_spct
[(x, i, j, drop = NULL)# S3 method for raw_spct
[(x, i, j, drop = NULL)
# S3 method for cps_spct
[(x, i, j, drop = NULL)
# S3 method for source_spct
[(x, i, j, drop = NULL)
# S3 method for response_spct
[(x, i, j, drop = NULL)
# S3 method for filter_spct
[(x, i, j, drop = NULL)
# S3 method for reflector_spct
[(x, i, j, drop = NULL)
# S3 method for solute_spct
[(x, i, j, drop = NULL)
# S3 method for object_spct
[(x, i, j, drop = NULL)
# S3 method for chroma_spct
[(x, i, j, drop = NULL)
# S3 method for generic_spct
[(x, i, j) <- value
# S3 method for generic_spct
$(x, name) <- value
An object of the same class as x
but containing only the
subset of rows and columns that are selected. See details for special
cases.
spectral object from which to extract element(s) or in which to replace element(s)
index for rows,
index for columns, specifying elements to extract or replace. Indices are
numeric or character vectors or empty (missing) or NULL. Please, see
Extract
for more details.
logical. If TRUE the result is coerced to the lowest possible dimension. The default is FALSE unless the result is a single column.
A suitable replacement value: it will be repeated a whole number of times if necessary and it may be coerced: see the Coercion section. If NULL, deletes the column if a single column is selected.
A literal character string or a name (possibly backtick quoted). For extraction, this is normally (see under 'Environments') partially matched to the names of the object.
These methods are just wrappers on the method for data.frame objects
which copy the additional attributes used by these classes, and validate
the extracted object as a spectral object. When drop is TRUE and the
returned object has only one column, then a vector is returned. If the
extracted columns are more than one but do not include w.length
, a
data frame is returned instead of a spectral object.
subset
and trim_spct
sun.spct[sun.spct[["w.length"]] > 400, ]
subset(sun.spct, w.length > 400)
tmp.spct <- sun.spct
tmp.spct[tmp.spct[["s.e.irrad"]] < 1e-5 , "s.e.irrad"] <- 0
e2q(tmp.spct[ , c("w.length", "s.e.irrad")]) # restore data consistency!
Run the code above in your browser using DataLab