gsubAb: Convenience function to remove a pattern from a column in a...

View source: R/makeQueryTable.R

gsubAbR Documentation

Convenience function to remove a pattern from a column in a data.frame

Description

Remove a pattern from a column, either modifying in place or creating a new column. The default pattern removes the prefix "anti-" or "Anti-", optionally followed by Human or human, then optionally a space or underscore

Usage

gsubAb(
  df,
  ab = "Antigen",
  pattern = "[Aa]nti-([Hh]uman)?([ _]?)",
  replacement = "",
  new_col = NA
)

Arguments

df

A data.frame or tibble

ab

(character(1), default "Antigen) Name of the column to remove prefixes from

pattern

(character(1)) A regular expression for matching in column ab.

replacement

(character(1)) Replacement value, default "" (i.e. remove)

new_col

(character(1), default NA Name of the column to add to df. If NA, column ab is modified

Value

df, where prefixes such as "anti-human" have been removed from column "ab".

Author(s)

Helen Lindsay

Examples

df <- data.frame(Antigen = c("anti-Human CD8", "anti-mouse CD8"))
gsubAb(df)

HelenLindsay/AbNames documentation built on June 6, 2023, 1:18 p.m.