photobiology (version 0.9.30)

Extract: Extract or replace parts of a spectrum

Description

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.

Usage

# 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 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

Arguments

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 Extract for more details.

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.

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.

Details

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.

See Also

subset and trim_spct

Examples

Run this code
# NOT RUN {
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 DataCamp Workspace