Learn R Programming

hyperSpec (version 0.98-20140523)

Arith: Arithmetical Operators: +, -, *, /, ^, %%, %/%, %*%

Description

The arithmetical operators +, -, *, /, ^, %%, %/%, and %*% for hyperSpec objects.

Usage

## S3 method for class 'hyperSpec,hyperSpec':
Arith(e1, e2)
## S3 method for class 'hyperSpec,matrix':
Arith(e1, e2)
## S3 method for class 'matrix,hyperSpec':
Arith(e1, e2)
## S3 method for class 'hyperSpec,numeric':
Arith(e1, e2)
## S3 method for class 'numeric,hyperSpec':
Arith(e1, e2)
## S3 method for class 'hyperSpec,missing':
Arith(e1, e2)
x %*% y

Arguments

e1, e2
Either two hyperSpec objects or one hyperSpec object and matrix of same size as hyperSpec[[]] or a scalar (numeric of length 1).
x, y
Either two hyperSpec objects or one hyperSpec object and one matrix of appropriate size.

Value

  • hyperSpec object with the new spectra matrix.

concept

  • hyperSpec arithmetic
  • hyperSpec arithmetical operators
  • hyperSpec matrix multiplication
  • hyperSpec plus
  • hyperSpec division
  • hyperSpec spectra conversion

Details

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 Arithmetic). The operators work also with one hyperSpec object and a numeric object or a matrices of the same size as the spectra matrix of the hyperSpec object.

With numeric vectors sweep is most probably more appropriate. If you want to calculate on the data.frame hyperSpec@data, you have to do this directly on hyperSpec@data.

See Also

sweep-methods for calculations involving a vector and the spectral matrix. S4groupGeneric for group generic methods.

Arithmetic for the base arithmetic functions.

matmult for matrix multiplications with %*%. Comparison for comparison operators, Math for mathematical group generic functions (Math and Math2 groups) working on hyperSpec objects.

Examples

Run this code
chondro + chondro
1 / chondro
all((chondro + chondro - 2 * chondro)[[]] == 0)
-flu

Run the code above in your browser using DataLab