ir_as_ir: Generic to convert objects to class 'ir'

View source: R/ir.R

ir_as_irR Documentation

Generic to convert objects to class ir

Description

ir_as_ir ir the generic to convert an object to an object of class ir.

Usage

ir_as_ir(x, ...)

## S3 method for class 'ir'
ir_as_ir(x, ...)

## S3 method for class 'data.frame'
ir_as_ir(x, ...)

Arguments

x

An object.

...

Further arguments passed to individual methods.

  • If x is a data frame or an object of class ir, these are ignored.

Value

An object of class ir.

Examples

# conversion from an ir object
ir::ir_sample_data %>%
  ir_as_ir()

# conversion from a data frame
x_ir <- ir::ir_sample_data

x_df <-
  x_ir %>%
  ir_drop_spectra() %>%
  dplyr::mutate(
    spectra = x_ir$spectra
  ) %>%
  ir_as_ir()

# check that ir_as_ir preserves the input class
ir_sample_data %>%
  structure(class = setdiff(class(.), "ir")) %>%
  dplyr::group_by(sample_type) %>%
  ir_as_ir()



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