| Extract {photobiology} | R Documentation |
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 class 'generic_spct' x[i, j, drop = NULL] ## S3 method for class 'raw_spct' x[i, j, drop = NULL] ## S3 method for class 'cps_spct' x[i, j, drop = NULL] ## S3 method for class 'source_spct' x[i, j, drop = NULL] ## S3 method for class 'response_spct' x[i, j, drop = NULL] ## S3 method for class 'filter_spct' x[i, j, drop = NULL] ## S3 method for class 'reflector_spct' x[i, j, drop = NULL] ## S3 method for class 'object_spct' x[i, j, drop = NULL] ## S3 method for class 'chroma_spct' x[i, j, drop = NULL] ## S3 replacement method for class 'generic_spct' x[i, j] <- value ## S3 replacement method for class 'generic_spct' x$name <- value
x |
spectral object from which to extract element(s) or in which to replace element(s) |
i |
index for rows, |
j |
index for columns, specifying elements to extract or replace. Indices are
numeric or character vectors or empty (missing) or NULL. Please, see
|
drop |
logical. If TRUE the result is coerced to the lowest possible dimension. The default is FALSE unless the result is a single column. |
value |
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. |
name |
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.
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.
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!