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

Matthew Dowle mdowle at mdowle.plus.com
Thu Dec 15 09:47:13 CET 2011


Yes, thanks. It occurs when DT is keyed, and, one of the key columns is
called 'x'. Change the 'x' to 'X' as a workaround and it works. This was
introduced in June in 1.6.1 when fixing another problem.

Now fixed in 1.7.8.  This was a simple and quick fix so no need to file
bug report.

Thanks.

On Wed, 2011-12-14 at 18:07 -0800, Steven C. Bagley wrote:
> 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
> 
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help




More information about the datatable-help mailing list