View source: R/makeQueryTable.R
addID | R Documentation |
Adds an ID column to a data frame
addID(
df,
id_cols = c("Antigen", "Study"),
new_col = "ID",
warn = TRUE,
sep = "__",
overwrite = TRUE,
verbose = TRUE
)
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 |
overwrite |
Should new_col be regenerated if it already exists in df? (logical(1), default: TRUE) |
verbose |
Should program status messages be printed? Default: TRUE |
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. If ID column already exists, this function will check if the ID uniquely identifies rows and will do nothing if this is the case. If the ID column exists and does not uniquely identify rows, it will be regenerated and overwritten.
df with an extra ID column
df with an additional ID column, by default named "ID", which uniquely identifies each row. The ID column is created by pasting together the columns named in id_cols, and adding numbers if this is insufficient to uniquely identify rows.
Helen Lindsay
df <- data.frame(Study = c("A", "B", "B"),
Antigen = c("CD4","CD8","CD8"))
addID(df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.