+
, -
, *
, /
, ^
, %%
, %/%
, %*%
for hyperSpec
ObjectsR/Arith.R
Arith.Rd
# S4 method for hyperSpec,hyperSpec Arith(e1, e2) # S4 method for hyperSpec,missing Arith(e1, e2) # S4 method for hyperSpec,numeric Arith(e1, e2) # S4 method for hyperSpec,matrix Arith(e1, e2) # S4 method for numeric,hyperSpec Arith(e1, e2) # S4 method for matrix,hyperSpec Arith(e1, e2) # S4 method for hyperSpec,hyperSpec %*%(x, y) # S4 method for hyperSpec,matrix %*%(x, y) # S4 method for matrix,hyperSpec %*%(x, y)
e1, e2 | or |
---|---|
x, y | either two one a vector which length equalling either the number of rows or the number of
wavelengths of the a scalar (numeric of length 1). |
hyperSpec
object with the new spectra matrix.
If
If the e2
is a hyperSpec
objects, its extra data columns will silently be
dropped silently.
You can use these operators in different ways:
e1 + e2 `+`(e1, e2) x <!-- %*% y `%*%`(x, y) --> -x
The arithmetical operators +
, -
, *
, /
, ^
, %%
, %/%
, and
%*%
work on the spectra matrix of the hyperSpec
object. They have their
usual meaning (see base::Arithmetic). The operators work also with
one hyperSpec
object and a numeric object or a matrix of the same
size as the spectra matrix of the hyperSpec
object.
With numeric vectors sweep()
may be more explicit.
If you want to calculate on the extra data as well, use the data.frame
hyperSpec@data
directly or as.data.frame(x)
.
sweep()
for calculations with a vector and the spectra matrix.
methods::S4groupGeneric for group generic methods.
base::Arithmetic for the base arithmetic functions.
Comparison for comparison operators, Math for mathematical group generic functions (Math and Math2 groups) working on hyperSpec objects.
base::matmult for matrix multiplications with %*%
.
C. Beleites
flu + flu#> hyperSpec object #> 6 spectra #> 3 data columns #> 181 data points / spectrum #> wavelength: lambda/nm [numeric] 405.0 405.5 ... 495 #> data: (6 rows x 3 columns) #> 1. spc: I[fl]/"a.u." [matrix, array181] 54.3000 133.6027 ... 589.299 #> 2. filename: filename [character] rawdata/flu1.txt rawdata/flu2.txt ... rawdata/flu6.txt #> 3. c: c / (mg / l) [numeric] 0.05 0.10 ... 0.31 / flu#> hyperSpec object #> 6 spectra #> 3 data columns #> 181 data points / spectrum #> wavelength: lambda/nm [numeric] 405.0 405.5 ... 495 #> data: (6 rows x 3 columns) #> 1. spc: I[fl]/"a.u." [matrix, array181] 0.03683241 0.01496976 ... 0.003393863 #> 2. filename: filename [character] rawdata/flu1.txt rawdata/flu2.txt ... rawdata/flu6.txt #> 3. c: c / (mg / l) [numeric] 0.05 0.10 ... 0.3#> [1] TRUE-flu#> hyperSpec object #> 6 spectra #> 3 data columns #> 181 data points / spectrum #> wavelength: lambda/nm [numeric] 405.0 405.5 ... 495 #> data: (6 rows x 3 columns) #> 1. spc: I[fl]/"a.u." [matrix, array181] -27.15000 -66.80133 ... -294.6495 #> 2. filename: filename [character] rawdata/flu1.txt rawdata/flu2.txt ... rawdata/flu6.txt #> 3. c: c / (mg / l) [numeric] 0.05 0.10 ... 0.3flu / flu$c#> hyperSpec object #> 6 spectra #> 3 data columns #> 181 data points / spectrum #> wavelength: lambda/nm [numeric] 405.0 405.5 ... 495 #> data: (6 rows x 3 columns) #> 1. spc: I[fl]/"a.u." [matrix, array181] 543.0000 668.0133 ... 982.165 #> 2. filename: filename [character] rawdata/flu1.txt rawdata/flu2.txt ... rawdata/flu6.txt #> 3. c: c / (mg / l) [numeric] 0.05 0.10 ... 0.3