splitUnnest: Split a column and create one row per entry

View source: R/splitUnnest.R

splitUnnestR Documentation

Split a column and create one row per entry

Description

Convenience function for splitting a column at a delimiter, unnesting (one row per value after splitting) and removing unnecessary whitespace. Default is to split at brackets. Returns a tibble tbl_df.

Usage

splitUnnest(
  df,
  ab = "Antigen",
  split = "[\\(\\)]",
  new_col = NA,
  exclude = NA
)

Arguments

df

A data.frame or tibble

ab

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

split

(character(1), default "[\(\)]") A regular expression for using with strsplit. The default expression splits at "(" or ")".

new_col

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

exclude

(character(1), default NA) a regex - do not split if ab matches.

Examples

df <- data.frame(Antigen = c("CD279 (PD-1)", "Mac-2 (Galectin-3)"))
splitUnnest(df, "Antigen", new_col = "Split")


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