[datatable-help] with=FALSE

Matthew Dowle mdowle at mdowle.plus.com
Tue May 1 10:37:06 CEST 2012


Ok, makes sense. Unless anyone else chimes in, happy to leave it as it is
then.
Thanks, Matthew

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




More information about the datatable-help mailing list