[datatable-help] unique

Matthew Dowle mdowle at mdowle.plus.com
Sun Jun 26 02:26:35 CEST 2011


The NA in the key seems to be the issue. duplicated.data.table calls
diff on the columns and assumes no NA in keys.
Can't remember - did we decide to disallow NA in keys? There were other
issues with NA in keys and some threads in the past.
Do you need the key to contain NA?
Matthew


On Sat, 2011-06-25 at 16:23 -0500, Damian Betebenner wrote:
> All,
> 
>  
> 
> I have a simple question regarding the behavior of unique with more
> than 1 key. Consider the example:
> 
>  
> 
> > dt <- data.table(X=c(NA,1,2,3), Y=c(NA,2,1,3))
> 
> > dt
> 
>       X  Y
> 
> [1,] NA NA
> 
> [2,]  1  2
> 
> [3,]  2  1
> 
> [4,]  3  3
> 
> > key(dt) <- c("X", "Y")
> 
> > unique(dt)
> 
>       X  Y
> 
> [1,] NA NA
> 
> [2,]  2  1
> 
> [3,]  3  3
> 
>  
> 
> If I understand this correctly, unique see rows 2 and 3 of dt as the
> same. 
> 
>  
> 
> Is this the behavior one wants?
> 
>  
> 
> Thanks for any clarification.
> 
>  
> 
> Damian
> 
>  
> 
>  
> 
> 
> _______________________________________________
> 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