rmdupkey: Remove observations with duplicate keys from data

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/rmdupkey.R

Description

Takes in a data and key, and returns data with duplicate observations by key removed

Usage

1

Arguments

data

a data.frame or data.table

by

a character vector of keys to be used

Details

Remove duplicate observations by key(s) is what this function does. How it is different from other functions that remove duplicates is that rmdupkey works for both 'data.frame' and 'data.table', and it also returns the duplicated observations.

Many a times we want to go back to the duplicated observations and see why that duplication occured. One can pick the duplicated observations using the code given in example.

Value

a two element list: unique data and duplicate data

Author(s)

Akash Jain

See Also

randomise, factorise, rmdupobs

Examples

1
2
3
4
5
6
7
# A 'data.frame'
df <- data.frame(x = c(1, 2, 1, 1), y = c(3, 3, 1, 3))

# Remove duplicate observations by key from data
ltDf <- rmdupkey(data = df, by = c('x'))
unqDf <- ltDf$unqData
dupDf <- ltDf$dupData

Example output



StatMeasures documentation built on May 2, 2019, 1:44 p.m.