Adds an ID column to a data frame
Usage
addID(
df,
id_cols = c("Antigen", "Study"),
new_col = "ID",
warn = TRUE,
sep = "__"
)
Arguments
- df
A data.frame or tibble
- id_cols
(character(n)) Names of columns to paste to form ID column
- new_col
(character(1), default: "ID") Name of new ID column
- warn
(TRUE/FALSE, default: TRUE) If TRUE, warn if IDs are not unique
- sep
(Default: __) Delimiter to use for pasting columns to form ID
Value
df with an extra ID column
Details
Pastes a group of columns together to form an ID column. If pasted values do
not uniquely identify rows, adds a number to the end.