Ops.ir: Arithmetic operations for 'ir' objects

View source: R/Ops.R

Ops.irR Documentation

Arithmetic operations for ir objects

Description

Arithmetic operations for ir objects

Usage

## S3 method for class 'ir'
Ops(e1, e2)

Arguments

e1

An object of class ir.

e2

An object of class ir or a numeric value.

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.

Examples

## addition
ir::ir_sample_data + ir::ir_sample_data
ir::ir_sample_data + 2

## subtraction
ir::ir_sample_data - ir::ir_sample_data
ir::ir_sample_data - 2

## multiplication
ir::ir_sample_data * ir::ir_sample_data
ir::ir_sample_data * 2

## division
ir::ir_sample_data / ir::ir_sample_data
ir::ir_sample_data / 2


ir documentation built on May 2, 2022, 5:06 p.m.