[datatable-help] Auto-convert characters to factors when settings keys?

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Aug 30 03:46:49 CEST 2010


Hi Matthew,

Thanks for the update and taking care of this!

-steve

On Sun, Aug 29, 2010 at 6:16 PM, Matthew Dowle <mdowle at mdowle.plus.com> wrote:
>
>
> setkey now coerces character to factor (as Steve suggested), and double to
> integer (provided they are all.equal).
>
>
> Steve Lianoglou wrote:
>>
>> Would it make sense to autoconvert characters to factors when setting
>> a character column as a key?
>> df <- data.frame(a=LETTERS[1:10], b=1:10, stringsAsFactors=F)
>> dt <- data.table(df)
>> key(dt) <- 'a'
>>   All keyed columns must be storage mode integer
>> dt <- data.table(df, key='a')
>> Error in setkey(value, a) :
>>   All keyed columns must be storage mode integer
>>
>
> That became bug #953, now fixed with tests 215-219 added.
>
>> df <- data.frame(a=LETTERS[1:10], b=1:10, stringsAsFactors=F)
>> dt <- data.table(df)
>> key(dt) <- 'a'
>> dt["C"]
>     a b
> [1,] C 3
>
>
> Matthew
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Auto-convert-characters-to-factors-when-settings-keys-tp2315281p2399401.html
> Sent from the datatable-help mailing list archive at Nabble.com.
> _______________________________________________
> 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
>



-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact


More information about the datatable-help mailing list