[datatable-help] with=FALSE

Cook, Malcolm MEC at stowers.org
Tue May 1 18:07:22 CEST 2012


+++1


On 4/30/12 2:48 PM, "Joseph Voelkel" <jgvcqa at rit.edu> wrote:

>Well, no one has chimed in yet, so I'll give it a shot.
>
>I see your logic, and I like your continual efforts to make the package
>neater, but my take would be to leave things as they are for consistency.
>I think it would be easier for new users to find that
>    DT[,c("colA","colB")]
>and 
>    colvars = c("colA","colB")
>    DT[,colvars]  
>both don't work, and realize they need to use with=FALSE, rather than
>finding that the two lead to different results.
>
>Joe Voelkel
>
>
>-----Original Message-----
>From: datatable-help-bounces at lists.r-forge.r-project.org
>[mailto:datatable-help-bounces at lists.r-forge.r-project.org] On Behalf Of
>Matthew Dowle
>Sent: Thursday, April 26, 2012 5:03 AM
>To: datatable-help at lists.r-forge.r-project.org
>Subject: [datatable-help] with=FALSE
>
>
>Dear Datatablers,
>
>It may be possible for these :
>
>    DT[,1]
>    DT[,1:3]
>    DT[,c("colA","colB")]
>
>all to return a data.table of those columns, rather than needing
>with=FALSE, for convenience. After all, there is no useful purpose of
>returning the j vector itself in these cases; the programmers intent is
>unambiguous (afaik).
>
>Where a variable holds the vector of column names or numbers, with=FALSE
>would still be needed.
>
>    colvars = c("colA","colB")
>    DT[,colvars]  # would return the column called colvars if exists, or
>the vector itself.
>    DT[,colvars,with=FALSE]   # with needed in this case
>
>Given with=FALSE would become optional in the simpler cases, I'm thinking
>it would be backwards compatible and wouldn't cause any problems to
>existing code. Unless, there is a valid reason to return the j vector
>straight back (a special case of a larger idiom perhaps)?
>
>Internally it would look at the j expression to see if it was a single
>column position, a call to ":" or a call to "c()", which resulted in a
>valid vector of column names or positions. Anything more complicated
>would need with=FALSE.  The risk would be inconsistency and confusion, or
>not maybe?
>
>This would change the very first FAQ (1.1), though. Not sure if it would
>make it easier or harder to make the transition to data.table.
>
>Thoughts?
>
>Matthew
>
>
>_______________________________________________
>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-hel
>p
>_______________________________________________
>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-hel
>p



More information about the datatable-help mailing list