[datatable-help] Question on inconsistent behavior

Steve Lianoglou mailinglist.honeypot at gmail.com
Tue Feb 8 19:26:07 CET 2011


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

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