Learn R Programming

spectrolab (version 0.0.18)

as.data.frame.spectra: 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 spectra
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  fix_names = "none",
  metadata = TRUE,
  ...
)

Value

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

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

Author

Jose Eduardo Meireles

Examples

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

Run the code above in your browser using DataLab