Learn R Programming

geoSpectral (version 0.17.5)

$,Spectra-method: Extract or replace parts of a Spectra object

Description

Operators acting on Spectra objects to extract parts

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

Usage

# S4 method for Spectra
$(x, name)

# S4 method for Spectra $(x, name) <- value

# S4 method for Spectra [(x, i, j)

# S4 method for Spectra,character,missing [[(x, i, j)

# S4 method for 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

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

# }

Run the code above in your browser using DataLab