Learn R Programming

ir (version 0.4.1)

Ops.ir: Arithmetic operations for ir objects

Description

Arithmetic operations for ir objects

Usage

# S3 method for ir
Ops(e1, e2)

Value

e1 with intensity values of the spectra added to/subtracted with/multiplied with/divided by those in e2:

  • If e2 is a numeric value, all intensity values in the spectra of e1 are added/subtracted/multiplied/divided by e2.

  • If e2 is an ir object with one row, it is replicated (see rep.ir) so that the row numbers match to those of e1 and intensity values are added/subtracted/multiplied/divided row-wise.

  • If e2 is an ir object with the same number of rows as e1, intensity values are added/subtracted/multiplied/divided row-wise.

Arguments

e1

An object of class ir.

e2

An object of class ir or a numeric value.

Examples

Run this code
## addition
ir::ir_sample_data + ir::ir_sample_data
ir::ir_sample_data + 2
ir::ir_sample_data +
   seq(from = 0, to = 2, length.out = nrow(ir::ir_sample_data))

## subtraction
ir::ir_sample_data - ir::ir_sample_data
ir::ir_sample_data - 2
ir::ir_sample_data -
   seq(from = 0, to = 2, length.out = nrow(ir::ir_sample_data))

## multiplication
ir::ir_sample_data * ir::ir_sample_data
ir::ir_sample_data * 2
ir::ir_sample_data *
   seq(from = 0, to = 2, length.out = nrow(ir::ir_sample_data))

## division
ir::ir_sample_data / ir::ir_sample_data
ir::ir_sample_data / 2
ir::ir_sample_data /
   seq(from = 0.1, to = 2, length.out = nrow(ir::ir_sample_data))

Run the code above in your browser using DataLab