Skip to contents

Some data will not be converted:

  • Spectra columns except the data_column

  • Wavenumber columns except the freq_column

Usage

simplerspec_to_ChemoSpec(
  spc_tbl,
  groups = "{missing group}",
  data_column = base::c("spc_pre", "spc_mean", "spc_rs", "spc"),
  freq_column = base::c("xvalues_pre", "wavenumbers_rs", "wavenumbers"),
  name_column = base::c("unique_id", "file_id", "sample_id", "sample_name"),
  .name_column_collapse = NULL,
  .strict_column_check = TRUE,
  ...
)

Arguments

spc_tbl

simplerspec::gather_spc, simplerspec::resample_spc, simplerspec::average_spc, or simplerspec::preprocess_spc spectra tibble.

groups

Factor with sample class assignments or single integer or string value. Length of factor must match nrow(data). A single value is treated as setting the same group for all samples. Defaults to "{missing group}"

data_column

Column name of the data to use. Must be one of "spc_pre", "spc_mean", "spc_rs", "spc", or any column name if strict_column_check is set to FALSE.

freq_column

Column name of the data to use. Must be one of "xvalues_pre", "wavenumbers_rs", "wavenumbers", or any column name if strict_column_check is set to FALSE.

name_column

Column name of the data to use. Must be one of "unique_id", "file_id", "sample_id", "sample_name", or any metadata column name if strict_column_check is set to FALSE.

.name_column_collapse

(Default: NULL) Optional string, that if set allows multiple metadata column names to be set in name_column, causing them to be concatenated using .name_column_collapse as a separator. This can be used with .strict_column_check = FALSE to construct custom sample identifiers using other metadata such as rep_no.

.strict_column_check

(Default: TRUE) Set this to FALSE to allow using any valid column name on spc_tbl in data_column and freq_column, and any metadata column names in name_column.

...

Arguments passed on to to_ChemoSpec

unit_frequency,unit_intensity

Optional labels for the x- and y-axis.

desc

Optional description for plots generated with ChemoSpec.

colors_set,sym_set,alt.sym_set

Character vector with group colors, Numeric vector with group symbol numbers, Character vector with alternative group symbols. Their length must match at least the number of levels in groups. Groups are assigned colors based on their numeric factor level. Defaults to ChemoSpecUtils::Col8, ChemoSpecUtils::Sym8 and base::letters. A color-blind friendly palette is available in ChemoSpecUtils::Col7. Extended palettes are available at ChemoSpecUtils::Col12, ChemoSpecUtils::Sym12, and using other packages, like RColorBrewer.

.strict_extra_data_names

(Default: TRUE) Set this to FALSE to allow columns from extra_data to overwrite values on the Spectra object.

Value

A ChemoSpec::Spectra() object.

See also

Examples

if (FALSE) {
  data("simplerspec_opus")
  simplerspec_to_ChemoSpec(
    simplerspec_opus,
    groups = factor(LETTERS[1:3])
  ) |> str()
}