[datatable-help] Problem with data.table and FastRWeb

Bacou, Melanie mel at mbacou.com
Wed Feb 19 07:37:36 CET 2014


Hi Matt,

Thanks very much for your detailed explanation, and for offering to 
patch data.table.

Adding
 > assignInNamespace("cedta.override", c("gWidgetsWWW","FastRWeb"), 
"data.table")
did the trick here.

Perfect! --Mel.


On 2/18/2014 5:43 AM, Matt Dowle wrote:
>
> Hi Mel,
>
> Thanks for the info.  It's likely related to cedta() and we can handle 
> it from data.table's side as follows.
>
> Background :
>
> http://stackoverflow.com/a/10529888/403310
>
> Type "data.table:::cedta" so you can see the rules.  I guess FastWeb 
> is running your code in its own environment.  First thing,  turn on 
> verbosity :
>
>     options(data.table.verbose=TRUE)     #  or for one statement 
> rather than globally,   d1[d2,verbose=TRUE]
>
> and run your code again.  You should see a message  "cedta decided 
> '<nsname>' wasn't data.table aware",  where <nsname> is probably 
> "FastRWeb".
>
> This calling environment (let's assume "FastRWeb" from now on) is more 
> like .GlobalEnv than a package;  i.e.,  it's where you run your own 
> code, you've done library(data.table) in that environment,  and so it 
> is data.table aware as far as you're concerned.  So what to do?  There 
> are two override mechanisms :
>
> The data.table package contains a character vector :
>
> > data.table:::cedta.override
> [1] "gWidgetsWWW"
>
> It already contains one package which is similar in nature.  You can 
> add FastRWeb to that vector yourself as follows :
>
> > assignInNamespace("cedta.override", c("gWidgetsWWW","FastRWeb"), 
> "data.table")
> > data.table:::cedta.override
> [1] "gWidgetsWWW" "FastRWeb"
>
> But I'll also add FastRWeb to that vector in data.table, so from the 
> next version of data.table you won't have to do it yourself.  We'll 
> add new packages as we become aware of them.
>
> Alternatively,  the package author (Simon in this case) can provide 
> data.table-awareness optionally.  This mechanism was added for dplyr 
> so it can control data.table awareness from the caller's end.  That's 
> done by setting a variable .datatable.aware=TRUE|FALSE in the calling 
> package's namespace.    However, in the case of FastRWeb,  the 
> cedta.override on data.table's side seems the right way to go.
>
> Matt
>
>
> On 18/02/14 05:31, Bacou, Melanie wrote:
>> Hi Arun,
>>
>> This is a little tricky to reproduce unless you have installed 
>> FastRWeb, and then started the FastRWeb server. I'm executing these 
>> scripts from the browser through a call to FastRWeb running on a 
>> local port.
>>
>> Installation is documented here and is quick and straightforward on 
>> Linux:
>> https://rforge.net/FastRWeb/
>> and an example here:
>> http://jayemerson.blogspot.mx/2011/10/setting-up-fastrwebrserve-on-ubuntu.html
>>
>> I'm using FastRWeb to build a simple web service. As long as I stick 
>> to data.frame methods, everything works fine and I get the expected 
>> plots and HTML output in the browser. But calls to data.table methods 
>> (merge, extract) all seem to default to data.frame, and I really 
>> don't know how to debug that.
>>
>> I am copying Simon Urbanek who's the maintainer of FastRWeb, in case 
>> this is more of a FastRWeb issue.
>>
>> Here is my session info (I am on CentOS 5 and cannot easily upgrade 
>> to R 3.0.2).
>>
>> > sessionInfo()
>> R version 2.15.2 (2012-10-26)
>> Platform: x86_64-redhat-linux-gnu (64-bit)
>>
>> locale:
>> [1] C
>>
>> attached base packages:
>> [1] stats     graphics  utils     datasets  grDevices methods base
>>
>> other attached packages:
>>  [1] ggmap_2.3          ggplot2_0.9.3.1    RColorBrewer_1.0-5 
>> raster_2.2-12
>>  [5] rgeos_0.3-3        rgdal_0.8-16       sp_1.0-14 data.table_1.8.10
>>  [9] RJDBC_0.2-3        rJava_0.9-6        DBI_0.2-7 rj_1.1.2-3
>>
>> loaded via a namespace (and not attached):
>>  [1] MASS_7.3-23         RJSONIO_1.0-3       RgoogleMaps_1.2.0.5
>>  [4] colorspace_1.2-4    dichromat_2.0-0     digest_0.6.4
>>  [7] grid_2.15.2         gtable_0.1.2        labeling_0.2
>> [10] lattice_0.20-24     mapproj_1.2-2       maps_2.3-6
>> [13] munsell_0.4.2       plyr_1.8            png_0.1-7
>> [16] proto_0.3-10        reshape2_1.2.2      rj.gd_1.1.0-1
>> [19] rjson_0.2.13        scales_0.2.3        stringr_0.6.2
>> [22] tools_2.15.2
>>
>> Thanks all!
>> --Mel.
>>
>>
>>
>>
>> On 2/17/2014 6:58 AM, Arunkumar Srinivasan wrote:
>>> Mel,
>>> I'm not able to reproduce this on 1.8.11. Which version are you using?
>>> I'm not aware of this package, and what 'otable' is supposed to do. 
>>> But I get no output while running your script, and not the error 
>>> message as well.
>>>
>>>
>>> On Mon, Feb 17, 2014 at 11:14 AM, Bacou, Melanie <mel at mbacou.com 
>>> <mailto:mel at mbacou.com>> wrote:
>>>
>>>     Hi,
>>>
>>>     I am testing an R script using FastRWeb (through Rserve).
>>>     FastRWeb works as expected and I can successfully runs Simon
>>>     Urbanek's examples. Problems arise when I try to merge
>>>     datatables. It seems FastRWeb cannot find merge.data.table().
>>>
>>>     I'm using plenty of other libraries (ggplot, raster, RJDBC,
>>>     etc.) that execute successfully through FastRWeb scripts, so I'm
>>>     guessing it's something peculiar to data.table.
>>>
>>>     Thanks for any help! --Mel.
>>>
>>>
>>>     Here are reproducible examples.
>>>
>>>     Test #1: the code below (the entire content of my R script)
>>>     SUCCEEDS:
>>>
>>>     # test1.R
>>>     library(data.table)
>>>
>>>     run <- function(...) {
>>>       oclear()
>>>       d1 <- data.table(a=c(1,2,3), b=c("a","b","c"))
>>>       d2 <- data.table(e=c("v","a","b"), f=c(4,6,7))
>>>       otable(d1)
>>>       otable(d2)
>>>     }
>>>
>>>     This returns a simple web page showing 2 tables:
>>>     1 	a
>>>     2 	b
>>>     3 	c
>>>
>>>     v 	4
>>>     a 	6
>>>     b 	7
>>>
>>>
>>>
>>>     Test #2: the code below (the entire content of my R script)
>>>     FAILS with:
>>>     Error in `[.default`(x, i) : invalid subscript type 'list'
>>>
>>>     # test2.R
>>>     library(data.table)
>>>
>>>     run <- function(...) {
>>>       oclear()
>>>       d1 <- data.table(a=c(1,2,3), b=c("a","b","c"))
>>>       d2 <- data.table(e=c("v","a","b"), f=c(4,6,7))
>>>       otable(d1)
>>>       otable(d2)
>>>       setkey(d1, b)
>>>       setkey(d2, e)
>>>       otable(d1[d2])
>>>     }
>>>
>>>
>>>
>>>
>>>     -- 
>>>     Melanie BACOU
>>>     International Food Policy Research Institute
>>>     Agricultural Economist, HarvestChoice
>>>     Work+1(202)862-5699  <tel:%2B1%28202%29862-5699>
>>>     E-mailmel at mbacou.com  <mailto:mel at mbacou.com>
>>>     Visitharvestchoice.org  <http://harvestchoice.org>  
>>>
>>>
>>>     _______________________________________________
>>>     datatable-help mailing list
>>>     datatable-help at lists.r-forge.r-project.org
>>>     <mailto:datatable-help at lists.r-forge.r-project.org>
>>>     https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>>>
>>>
>>
>> -- 
>> Melanie BACOU
>> International Food Policy Research Institute
>> Agricultural Economist, HarvestChoice
>> Work +1(202)862-5699
>> E-mailmel at mbacou.com
>> Visit harvestchoice.org
>>
>>
>> _______________________________________________
>> 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
>

-- 
Melanie BACOU
International Food Policy Research Institute
Agricultural Economist, HarvestChoice
Work +1(202)862-5699
E-mail mel at mbacou.com
Visit harvestchoice.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20140219/9fc5e826/attachment.html>


More information about the datatable-help mailing list