tests/testthat/test_conversion.R

library("testthat")
library("spectrolab")

context("Spectra conversion")

test_that("matrix is converted to spectra", {
    expect_s3_class( as_spectra(spec_matrix_example, name_idx = 1), "spectra" )
})

test_that("data frame is converted to spectra", {
    expect_s3_class( as_spectra( as.data.frame(spec_matrix_example), name_idx = 1), "spectra" )
})

test_that("spectra is converted to matrix", {
    expect_true( is.matrix(as.matrix( as_spectra(spec_matrix_example, name_idx = 1) )))
})

Try the spectrolab package in your browser

Any scripts or data that you put into this service are public.

spectrolab documentation built on Feb. 16, 2023, 10:27 p.m.