[datatable-help] Error when using eval() in j

Harish harishv_99 at yahoo.com
Sat Aug 14 10:08:19 CEST 2010


I am running into an issue using a quote with eval in 'j'.  I think I had a similar issue with 'by' in the past; maybe it is a similar bug.

Use the following code to reproduce:
---------------------

foo <- function( data, fcn ) {
   q <- substitute( fcn )
   
   # The following line works
   #data[ , eval( q ), by=a ]

   # The following line causes an error
   data[ , eval( substitute( fcn ) ), by=a ]
}

num <- 10
DT <- data.table( a=rep(c("A","B"),num), b=1:(num*2) )
foo( DT, sum(b) )

---------------------

Notice the two lines inside foo().  They should be logically equivalent, but only one works.

Is this a bug?


Harish



      


More information about the datatable-help mailing list