dupCols | R Documentation |
Identify duplicated column names in a data.table. Print them to console and optionally remove them from data.table. Will keep the first (or last) occurrence of a column name and remove all subsequent occurrences.
dupCols(data_dt, rev_v = F, remove_v = T, verbose_v = F)
data_dt |
input data.table with duplicated columns |
rev_v |
logical. TRUE - keep last occurrence of duplicated name; FALSE (default) keep 1st occurrence |
remove_v |
logical, TRUE - remove columns; FALSE - do not remove, just print column names to console (if verbose) |
verbose_v |
logical. TRUE - print out duplicated columns. FALSE - do not print |
data.table same as data_dt, optionally with extra columns removed.
dat <- data.table("A" = 1:5, "B" = 6:10, "A" = 11:15)
dupCols(dat)
dupCols(dat, rev_v = T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.