data.table and R's ellipsis (i.e. '...'): pass by reference does not seem to work -


im trying manipulate large data table (~37 mb) in special way: other (unrelated) reasons have implemented 'hook' structure meaning overall process like

1) load data.table disk

2) fire hook

3) hook structure looks name ans checks whether user (=me :)) has bound function hook , if so, called

4) data processed further

the functions this:

data = readrds(pathtofile) data = data.table(data) firehook("after_data_read", data, [some other parameters]) some_more_processing(data) 

and region around firehook looks like

hooksregistered = list(   "after_data_read" = function(data, ...) {                          # stuff                        }   )  firehook = function(hookname, ...) {   (hooknameregistered in names(hooksregistered)) {     if (hookname == hooknameregistered) {       func = .global.hooksregistered[[hookname]]       func(hookname, ...)     }   } } 

observe 1 needs cast object is data.table again (otherwise pass-by-reference not work), see adding new columns data.table by-reference within function not working , pass reference bug?


problem: line: func(hookname, ...) takes forever (> 5 minutes).


the debugger never gets function (so not code in function takes long time) , i've tested small data.tables , worked. also, noted following seems work:

firehook = function(hookname, ...) {   args = list(...)   (hooknameregistered in names(.global.hooksregistered)) {     if (hookname == hooknameregistered) {       func = .global.hooksregistered[[hookname]]       func(hookname, args)     }   } } 

(notice substituted ... list(...)). me, seems if r trying copy whole table when using .... right/desired? or using wrong?

regards,

fw


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -