as.data.frame.spectra: Convert spectra to data.frame

View source: R/conversion.R

as.data.frame.spectraR Documentation

Convert spectra to data.frame

Description

Returns a data.frame that includes sample names, metadata (if present) and value data. One advantage over as.matrix, is that the metadata are returned.

Usage

## S3 method for class 'spectra'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  fix_names = "none",
  metadata = TRUE,
  ...
)

Arguments

x

spectra object

row.names

does nothing. Here for compatibility with S3 generics

optional

does nothing. Here for compatibility with S3 generics

fix_names

Use make.names to normalize names? Pick one: "none" "row" "col" "both".

metadata

boolean. Include spectral metadata? Defaults to TRUE

...

extra parameters passed to the generic as_spectra

Value

data.frame with: sample_name, metadata (if any) and value.

Author(s)

Jose Eduardo Meireles

Examples

library(spectrolab)
spec = as_spectra(spec_matrix_example, name_idx = 1)
df   = as.data.frame(spec, fix_names = "none")

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