[datatable-help] calling unique on data table with a key

Steven C. Bagley steven.bagley at gmail.com
Thu Dec 15 03:07:22 CET 2011


Is this a bug? (Mac OS X 10.6.8, R 2.14.0, data.table 1.7.6)

> library(data.table)
data.table 1.7.6  For help type: help("data.table")
> df=data.frame(x=c("a", "a", "b", "b"), y=c("a", "a", "b", "b"))
> df
  x y
1 a a
2 a a
3 b b
4 b b
> unique(df)
  x y
1 a a
3 b b
> dt=as.data.table(df)
> dt
     x y
[1,] a a
[2,] a a
[3,] b b
[4,] b b
> unique(dt)
     x y
[1,] a a
[2,] b b
> setkey(dt, x)
> unique(dt)
Error in `[.default`(x, , key(x), with = FALSE) : 
  incorrect number of dimensions


--Steve



More information about the datatable-help mailing list