fillCoreSpectraVariables: Fill spectra data with columns for missing core variables

View source: R/MsBackend-functions.R

fillCoreSpectraVariablesR Documentation

Fill spectra data with columns for missing core variables

Description

fillCoreSpectraVariables() fills a provided data.frame with columns for eventually missing core spectra variables. The missing core variables are added as new columns with missing values (NA) of the correct data type. Use coreSpectraVariables() to list the set of core variables and their data types.

Usage

fillCoreSpectraVariables(
  x = data.frame(),
  columns = names(coreSpectraVariables())
)

Arguments

x

data.frame or DataFrame with potentially present core variable columns.

columns

character with the names of the (core) spectra variables that should be added if not already present in x. Defaults to columns = names(coreSpectraVariables()).

Value

input data frame x with missing core variables added (with the correct data type).

Examples


## Define a data frame
a <- data.frame(msLevel = c(1L, 1L, 2L), other_column = "b")

## Add missing core chromatogram variables to this data frame
fillCoreSpectraVariables(a)

## The data.frame thus contains columns for all core spectra
## variables in the respective expected data type (but filled with
## missing values).

rformassspectrometry/Spectra documentation built on Feb. 22, 2025, 8:38 p.m.