[datatable-help] Change names of a data.table, key stays old name

Matthew Dowle mdowle at mdowle.plus.com
Fri Aug 5 09:59:01 CEST 2011


Agreed, well spotted.  Please enter a :
     bug.report(package="data.table").
Matthew

"Chris Neff" <caneff at gmail.com> wrote in message 
news:CAAuY0RVQ5aUJP53HG54P7xtzxbStpjgv0CqdVyT=pWE_pLZ0Xg at mail.gmail.com...
> Quick example:
>
>> DT <- data.table(x=1:10,y=1:10)
>
>> key(DT) <- "x"
>
>> names(DT) <- c("a", "b", "c")
>
>> key(DT)
> [1] "x"
>
>
> This doesn't seem to be right.  An error happens if I do some things:
>
>> x[J(5)]
> Error in `[.data.table`(x, J(5)) :
>  sorted columns of x don't exist in the colnames. data.table is not a
> valid data.table
>
> But other things work fine still:
>
>> x[a == 5, ]
> [1,] 5 6 6
>
>
> When names get changed, the key names should be updated to reflect that, 
> no?
>
> -Chris 





More information about the datatable-help mailing list