[datatable-help] Change names of a data.table, key stays old name
Chris Neff
caneff at gmail.com
Fri Aug 5 12:56:35 CEST 2011
Submitted here:
https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1495&group_id=240&atid=975
On 5 August 2011 03:59, Matthew Dowle <mdowle at mdowle.plus.com> wrote:
> 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
>
>
>
> _______________________________________________
> 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