class_from_feature: create class from features

View source: R/utils.R

class_from_featureR Documentation

create class from features

Description

Given a data.frame, take a feature column, and create a class column from it.

Usage

class_from_feature(
  data,
  in_column = "feature",
  new_column = "class",
  sep = ".",
  n_sep = 10,
  position = 1
)

Arguments

data

the data.frame to use

in_column

the column that has the features

new_column

the column to store the data in

sep

the separator

n_sep

how many separators are expected?

position

which position the class is in after separation

Examples


data <- data.frame(feature = c("FA.15.0.15...NH4.C15H30O2..pos", "FA.16.2.16...NH4.C16H28O2..pos",
  "FA.18.2.18...NH4.C18H32O2..pos", "FA.19.2.19...NH4.C19H34O2..pos",
  "FA.21.1.21...H.C21H40O2..pos", "MAG.18.1.21...NH4.C21H40O4..pos",
  "FA.24.5.24...Na.C24H38O2..pos", "MAG.20.2.23...NH4.C23H42O4..pos",
  "DAG.22.2.25...NH4.C25H44O5..pos", "LysoPC.16.1.24...H.C24H48N1O7P1..pos"),
    stringsAsFactors = FALSE)

data <- class_from_feature(data)


rmflight/metabolomicsUtilities documentation built on Oct. 28, 2023, 6:41 p.m.