[datatable-help] can I count on data.table supporting syntactically invalid column names?

Matthew Dowle mdowle at mdowle.plus.com
Wed Aug 8 11:49:15 CEST 2012


Meant to write 2nd paragraph as follows :

>
> Hi. Yes you should be able to rely on that. It's useful to have special
> characters in column names for latex formatting, and spaces are allowed
> too. There are tests for these things. If you need to refer to such column
> names as variables, then it's up to you to wrap with ``; e.g.,
> by=`Illegal(name%)`+1.
>
> So yes, if you find problems with special characters, please report as
> bugs, and suggest where the documentation needs improving would be great.
>
> I seem to remember a bug fix in this regard, and in particular in merge
> (so my first thought is to ask you if you've recently upgraded to 1.8.2
> and if test.data.table returns 717), but as you say R-Forge is currently
> down for maintenance...
>
> That neworder error looks familiar too. Are you sure you have 1.8.2
> running in memory? (Run test.data.table() to see if it returns 717).
>
> Matthew
>
>> I'm taking advantage of a feature in data.table which lets me get away
>> with naming columns with characters that would not survive a call to
>> make.names(), e.g.:
>>
>>> DT1 = data.table(a=letters[1:5], "Illegal(name%)"=1:5, key="a")
>>> DT1
>>    a Illegal(name%)
>> 1: a              1
>> 2: b              2
>> 3: c              3
>> 4: d              4
>> 5: e              5
>>
>> (The the dcast function from the reshape2 package will also create
>> columns
>> named "illegally".)
>>
>> But when using merge.data.table, I get two side-effects; either the
>> merge
>> works, but the column names appear to be run through make.names(), or
>> the
>> merge fails in setcolorder():
>>
>>> DT1 = data.table(a=letters[1:5], "Illegal(name%)"=1:5, key="a")
>>> DT2 = data.table(a=letters[1:5], b=6L, key="a")
>>
>>> merge(DT1,DT2)
>>    a Illegal.name.. b
>> 1: a              1 6
>> 2: b              2 6
>> 3: c              3 6
>> 4: d              4 6
>> 5: e              5 6
>>
>>> merge(DT2,DT1)
>> Error in setcolorder(dt, c(setdiff(names(dt), end), end)) :
>>   neworder is length 4 but x has 3 columns.
>>
>> I can't get to datatable.r-forge.r-project.org - getting a 504.
>>
>> So... should I NOT rely on being able to use special characters in
>> column
>> names?
>>
>> Thanks
>> George
>>
>>> sessionInfo()
>> R version 2.15.0 (2012-03-30)
>> Platform: x86_64-unknown-linux-gnu (64-bit)
>> [1] data.table_1.8.2
>> _______________________________________________
>> 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
>
>
> _______________________________________________
> 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