For just two columns you can use the following trick:
dt = data.table(a = letters[1:5], b = letters[5:1])
# a b
#1: a e
#2: b d
#3: c c
#4: d b
#5: e a
dt[dt[, .I[1], by = list(pmin(a, b), pmax(a, b))]$V1]
# a b
#1: a e
#2: b d
#3: c c
More Related Contents:
- How can I remove all duplicates so that NONE are left in a data frame?
- Filtering out duplicated/non-unique rows in data.table
- Merging rows with the same ID variable [duplicate]
- data.table objects assigned with := from within function not printed
- Add ID column by group [duplicate]
- Unique rows, considering two columns, in R, without order
- .EACHI in data.table?
- Use a value from the previous row in an R data.table calculation
- How to efficiently calculate distance between pair of coordinates using data.table :=
- Unique on a dataframe with only selected columns
- Sample random rows within each group in a data.table
- Melt using patterns when variable names contain string information – avoid coercion to numeric
- Error: package or namespace load failed for ggplot2 and for data.table
- Split text string in a data.table columns
- Find duplicated rows (based on 2 columns) in Data Frame in R
- Why is allow.cartesian required at times when when joining data.tables with duplicate keys?
- Update subset of data.table based on join
- knitr gets tricked by data.table `:=` assignment
- Add multiple columns to R data.table in one function call?
- data.table equivalent of tidyr::complete()
- data.table merge based on date ranges
- Reason behind speed of fread in data.table package in R
- data.table row-wise sum, mean, min, max like dplyr?
- Combining duplicated rows in R and adding new column containing IDs of duplicates
- How to select R data.table rows based on substring match (a la SQL like)
- Subset data.table by logical column
- Any way to force fread() of data.table not to stop on empty lines?
- R data table: update join
- Split a string column into several dummy variables
- R fast single item lookup from list vs data.table vs hash