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

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Jun 28 05:57:53 CEST 2010


Hi,

On Sun, Jun 27, 2010 at 6:47 PM, Matthew Dowle <mdowle at mdowle.plus.com> wrote:
> I went back to try again with S3 inheritance, discussed further up in
> this thread.  Just committed as it seems, so far, to work.
>
> * data.table now inherits from data.frame i.e. class =
> c("data.table","data.frame")
> * is.data.frame() now returns TRUE for data.table
> * data.table should now be compatible with functions and packages that
> _only_ accept data.frame.

Perhaps I lost the point of this conversation somewhere along the way,
but this change makes it *technically* compatible since a data.table
passes an is.data.frame test, but it doesn't work in ways that are
perfectly acceptable for some function accepting a data.frame to work,
ie:

R> library(data.table)
R> dt <- data.table(a=1:5, b=letters[1:5], c=sample(1:100, 5))
R> dt[,c('b', 'c')]
[1] "b" "c"

instead of

R> df <- as.data.frame(dt)
R> df[,c('b', 'c')]
  b  c
1 a 18
2 b 11
3 c  2
4 d 50
5 e 96

Unless you were talking about making more changes to make a data.table
act more like a data.frame, I'm not sure allowing the user to ignore
the differences between data.table/frames is really a win/win
situation.

Sorry if I missed something.
-steve

-- 
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