updateGroups: Update Group Names in a Spectra or Spectra2D Object

Description Usage Arguments Value Examples

View source: R/updateGroups.R

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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 documentation built on March 16, 2021, 1:08 a.m.