dupCols: Duplicated Columns

View source: R/dupCols.R

dupColsR Documentation

Duplicated Columns

Description

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.

Usage

dupCols(data_dt, rev_v = F, remove_v = T, verbose_v = F)

Arguments

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

Value

data.table same as data_dt, optionally with extra columns removed.

Examples

dat <- data.table("A" = 1:5, "B" = 6:10, "A" = 11:15)
dupCols(dat)
dupCols(dat, rev_v = T)

weshorton/wrh.rUtils documentation built on Oct. 28, 2024, 7:24 a.m.