Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

updateGroups

Update Group Names in a Spectra or Spectra2D Object


Description

A convenience function that can be used to update (change) group names. The default group names come from the gr.crit argument in the import functions files2SpectraObject, matrix2SpectraObject or files2Spectra2DObject. In some cases gr.crit may have complex regex patterns, and this function makes updating them to more appropriate/more readible strings easier.

Usage

updateGroups(spectra, new.grps = NULL, silent = FALSE)

Arguments

spectra

An object of S3 class Spectra or Spectra2D.

new.grps

A vector of character values giving the new group names. The new values must correspond to the order of the old values. This vector should give the unique values only (so, it should have length(unique(spectra$groups))). If not provided, the function will print the old values for reference.

silent

Logical. If TRUE, suppresses all reporting.

Value

spectra An updated object of S3 class Spectra or Spectra2D.

Examples

if (checkForPackageWithVersion("ChemoSpec", "5.1")) {
  library("ChemoSpec")
  data(metMUD1)
  metMUD1a <- updateGroups(metMUD1) # reports old groups
  metMUD1a <- updateGroups(metMUD1, new.grps = c("C", "T"))
}

if (checkForPackageWithVersion("ChemoSpec2D", "0.3")) {
  library("ChemoSpec2D")
  data(MUD1)
  MUD1a <- updateGroups(MUD1, new.grps = c("control", "treatment"))
}

ChemoSpecUtils

Functions Supporting Packages ChemoSpec and ChemoSpec2D

v0.4.96
GPL-3
Authors
Bryan A. Hanson [aut, cre] (<https://orcid.org/0000-0003-3536-8246>)
Initial release
2021-03-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.