| map_column | R Documentation |
Maps values in a column of a data.frame (query) to new values using a named
vector or list (map), optionally creating a new column or replacing the original.
map_column(
query,
by,
map,
to = "mapped",
overwrite = FALSE,
default = "unknown",
preview = TRUE
)
query |
A data.frame containing the column to be mapped. |
by |
A string. Column name in |
map |
A named vector or list. Names are original values, values are mapped values. |
to |
A string. Name of the column to store mapped results (if |
overwrite |
Logical. Whether to replace the |
default |
Default value to assign if no match is found. Default: "unknown". |
preview |
Logical. Whether to print preview of result (default TRUE). |
A data.frame with a new or modified column based on the mapping (returned invisibly).
df <- data.frame(gene = c("TP53", "BRCA1", "EGFR", "XYZ"))
gene_map <- c("TP53" = "Tumor suppressor", "EGFR" = "Oncogene")
map_column(df, by = "gene", map = gene_map, to = "label")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.