bind: Combine colorSpec Objects

View source: R/colorSpec.ops.R

bindR Documentation

Combine colorSpec Objects

Description

Take a sequence of colorSpec objects and combine their spectra

Usage

## S3 method for class 'colorSpec'
bind( ... )

Arguments

...

colorSpec objects with the same wavelength and quantity, and with distinct specnames (no duplicates)

Details

The organization of the returned object is the most complex of those in the inputs, where the order of complexity is:

'matrix' < 'df.col' < 'df.row'

If the selected organization is 'df.row', the extradata is combined in a way that preserves all the columns. Missing data is filled with NAs, analogous to rbind.fill().

The metadata of the returned object is copied from the first object in the input list.

Value

bind() returns a colorSpec object, or NULL in case of ERROR. If the bind is successful, the number of spectra in the output object is the sum of the number of spectra in the input objects.

See Also

wavelength, quantity, specnames, organization, extradata, metadata, rbind.fill()

Examples

Rosco = readSpectra( system.file( 'extdata/objects/Rosco.txt', package='colorSpec' ) )
Rosco = resample( Rosco, wave=wavelength(Hoya) )
numSpectra(Hoya)        # prints 4
numSpectra(Rosco)       # prints 42

filters = bind( Hoya, Rosco )
numSpectra(filters)     # prints 46

colnames( extradata(Hoya) )
## [1] "SAMPLE_NAME"  "FresnelReflectance"  "Thickness"

colnames( extradata(Rosco) )
## [1] "Model"  "SampleID"  "SAMPLE_NAME"  "Substrate"  "RefractiveIndex"  "Thickness"

##  The columns in common are "SAMPLE_NAME" and "Thickness"


colnames( extradata(filters) )
## [1] "FresnelReflectance" "Model" "RefractiveIndex" "SAMPLE_NAME"
## [5] "SampleID" "Substrate" "Thickness"
##
## "SAMPLE_NAME" and "Thickness" are combined in the usual way
## The other columns are present, and missing data is filled with NAs

colorSpec documentation built on May 29, 2024, 6 a.m.