Learn R Programming

colorSpec (version 0.5-2)

colorSpec: constructing and testing colorSpec Objects

Description

The function colorSpec is used to construct colorSpec objects. is.colorSpec tests whether an object is a valid colorSpec object.

Usage

colorSpec( data, wavelength, quantity='auto', organization='auto' )

is.colorSpec(x)

Arguments

data
a vector or matrix of the spectrum values. In case data is a vector, there is a single spectrum and the number of points in that spectrum is the length of the vector. In case data is a matrix, the spectra are store
wavelength
a numeric vector of wavelengths for all the spectra. The length of this vector must be equal to NROW(data). The sequence must be increasing.
quantity
a character string giving the quantity of all spectra; see quantity for a list of possible values. In case of 'auto', a guess is made from the column names. This
organization
a character string giving the desired organization of the returned colorSpec object. In case of 'auto', the organization is 'vector' or 'matrix' depending on data. Other possi
x
an Robject to test for validity.

Value

  • colorSpec returns a colorSpec object, or NULL in case of ERROR. is.colorSpec returns TRUE or FALSE. If FALSE it logs helpful reasons that x is invalid.

Details

A colorSpec object is either a vector, matrix, or data.frame. It is of S3 class 'colorSpec' with these extra attributes: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

See Also

wavelength, quantity, metadata, step.wl, specnames, is.regular, coredata

Examples

Run this code
#  make a synthetic Gaussian bandpass filter

center = 600
wave   = 400:700
trans  = exp( -(wave-center)^2 / 20^2 )

filter.bp   = colorSpec( trans, wave, 'transmittance' )

organization( filter.bp )  # returns: [1] "vector"

specnames( filter.bp ) = "myfilter"

# and now plot it
plot( filter.bp )

Run the code above in your browser using DataLab