Learn R Programming

PlotFTIR (version 1.2.0)

rename_plot_sample_ids: Rename Sample IDs in Plot

Description

This function permits renaming Sample IDs as shown in the legend of a plot. While typically having proper names assigned in the data is preferred, this function allows for names to be modified after plot creation.

Cette fonction permet de renommer les identifiants des échantillons dans la légende d'un tracé. Bien qu'il soit préférable d'attribuer les noms appropriés dans les données, cette fonction permet de modifier les noms après la création du tracé.

Usage

rename_plot_sample_ids(ftir_spectra_plot, sample_ids)

Value

the FTIR plot as a ggplot2 object, with samples renamed in the legend.

le tracé IRTF en tant qu'objet ggplot2, avec les échantillons renommés dans la légende.

Arguments

ftir_spectra_plot

A plot generated by plot_ftir() or plot_ftir_stacked().

Un tracé généré par plot_ftir() ou plot_ftir_stacked().

sample_ids

A named vector of format "new name" = "old name". Must include all sample ID old names (a pair of "old name" = "old name" is permissible and results in no renaming for that sample).

Un vecteur nommé du format "nouveau nom" = "ancien nom". Doit inclure tous les anciens noms d'ID d'échantillon (une paire de "ancien nom" = "ancien nom" est autorisée et n'entraîne aucun changement de nom pour cet échantillon).

Examples

Run this code
if (requireNamespace("ggplot2", quietly = TRUE)) {
  # Generate a plot
  p <- plot_ftir(sample_spectra)

  # Rename Samples in Legend:
  new_ids <- c(
    "Toluene" = "toluene", "C7 Alkanes" = "heptanes", "IPA" = "isopropanol",
    "White Paper" = "paper", "PS Film" = "polystyrene"
  )
  rename_plot_sample_ids(p, new_ids)
}

Run the code above in your browser using DataLab