[datatable-help] Question on inconsistent behavior

Matthew Dowle mdowle at mdowle.plus.com
Tue Feb 8 19:53:00 CET 2011


test.data.table() has the same issue.

There was a thread on r-devel recently when somebody asked a very
similar question about another package, unrelated to data.table. Core
was basically saying NOTES were fine. They got very specific that they
are *not* warnings but NOTES! :-) They don't prevent the package being
accepted on CRAN.

However, I'm like you and prefer to have "OK" all the way down the
CRAN results page. That way users really do know it's fine (quickly). So
in test.data.table I just put a line of variables near the top to keep R
CMD check quiet.  It's only as bad as declaring variables in something
like C anyway.  Actually it's quite nice...I've found and fixed a few
problems that way.  See top of test.data.table.

The difference between DT[,SCORE] and DT[,list(SCORE)] is covered by FAQ
1.3.  At the top of your function just put in a SCORE=NULL.

On Tue, 2011-02-08 at 13:26 -0500, Steve Lianoglou wrote:
> Hi,
> 
> On Tue, Feb 8, 2011 at 1:19 PM, Damian Betebenner <dbetebenner at nciea.org> wrote:
> > All,
> >
> > In using data.table within a package I develop, I’m trying to avoid those
> > pesky warnings about variables not having a binding. Because data.table
> > scopes within the existing frame and code.tools isn’t smart enough to detect
> >
> > that, I’m getting a few of those pesky errors.
> >
> >
> >
> > This brought me to the following inconsistent behavior (at least it appears
> > that way to me):
> >
> >
> >
> > tmp.dt <- data.table(ID=1:10, SCORE=rnorm(10))
> >
> >
> >
> > tmp.dt[,SCORE]
> >
> >
> >
> > and
> >
> >
> >
> > tmp.dt[,”SCORE”, with=FALSE]
> >
> >
> >
> > The first returns a numeric vector whereas the second produces a
> > data.table/data.frame with a single column. The second avoids those pesky
> > warnings about unbound variables but I’d prefer to get the result provided
> > by the
> 
> How about:
> 
> R> tmp.dt$SCORE
> R> tmp.dt[['SCORE']]
> 
> -steve
> 




More information about the datatable-help mailing list