Spectra-Access: Extract or replace parts of a 'Spectra' object

Description Usage Arguments Details Examples

Description

Operators acting on Spectra objects to extract parts

Operators acting on Spectra object and Spectra lists to extract or replace parts.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## S4 method for signature 'Spectra'
x$name

## S4 replacement method for signature 'Spectra'
x$name <- value

## S4 method for signature 'Spectra'
x[i, j]

## S4 method for signature 'Spectra,character,missing'
x[[i, j]]

## S4 replacement method for signature 'Spectra,character,missing'
x[[i, j]] <- value

Arguments

x

A Spectra object from which to extract element(s) or in which to replace element(s)

name

A character (column name) or a numeric (column index) variable

value

A vector or matrix or data.frame. Values to be replaced with matched Spectra column.

i

A numeric (row index) variable

j

A character (column name) or a numeric (column index) variable

Details

These operators are generic. You can write methods to handle indexing of specific classes of objects

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 sp<-spc.example_spectra()
 # spc.colnames() is used to extract column names
 head(spc.colnames(sp))
 head(sp$anap_300)
 sp[,"anap_345"]
 sp[,"anap_345"] #returns Spectra object with only one channel (column)
 sp[1:3,"anap_345"] #returns Spectra object with first 3 rows and only one channel (column)
 # spc.colnames() is used to extract column names
 head(spc.colnames(sp))
 head(sp$anap_300)
 sp[,"anap_345"]
sp=spc.example_spectra()
sp #501 spectral channels in columns and 26 observations in rows 
sp[1] #returns Spectra object, 501 spectral channels in columns and 1 observations in rows
names(sp)
sp[["CAST"]] #returns the CAST data column
sp[[4]] #returns the CAST data column
sp[["CAST"]]=12 #Modify the CAST column
sp[["CAST"]] #returns the CAST data column

PranaGeo/Spectral documentation built on Feb. 21, 2020, 12:36 p.m.