[datatable-help] Conflict in the use of "J" between the packages.

Matthew Dowle mdowle at mdowle.plus.com
Mon Jan 16 15:16:14 CET 2012


Hi Jim,

Interesting. Not seen this one before. Please file a bug report for it.

Three options :

1. data.table already substitutes i before evaluating it. We could 'catch'
J there, and even remove the J function definition altogether.

2. You can use list() instead of J. That's a bit faster by avoiding the
call to data.table() inside J. For example :

> DT = data.table(a=1:3,key="a")
> DT
     a
[1,] 1
[2,] 2
[3,] 3
> DT[J(2)]
     a
[1,] 2
> DT[list(2L)]  # Same. Need the 'L' in this form, but it's faster.
     a
[1,] 2
> DT[list(2)]   # error is correct
Error in `[.data.table`(DT, list(2)) :
  unsorted column V1 of i is not internally type integer. i doesn't need
to be keyed, just convert the (likely) character column to factor

3. Both the above. i.e. remove J from the package and implement it inside
[.data.table more efficiently by replacing J with list before evaluation.
And I notice J coerces double to integer via a copy, which could be
avoided that way to.

What do you think?  If anyone uses J independently (i.e. not in i) are
they ok defining the alias J=data.table themselves?

Btw, the Chris crash is fixed (tbc) and v1.7.8 is almost ready.

Matthew



> I was having some problems with some code and noticed that there is a
> conflict in the use of "J" between the packages 'data.table' and
> 'XLConnect'.
>
> Is there some way around them if I want to use these packages together?
>
> ===================================
>> require(plyr)
> Loading required package: plyr
>> J
> Error: object 'J' not found
> No suitable frames for recover()
>> require(data.table)
> Loading required package: data.table
> data.table 1.7.7  For help type: help("data.table")
>> require(XLConnect)
> Loading required package: XLConnect
> Loading required package: XLConnectJars
> Loading required package: rJava
>
> Attaching package: ‘rJava’
>
> The following object(s) are masked from ‘package:data.table’:
>
>     J
>
> XLConnect 0.1-7 by Mirai Solutions GmbH <xlconnect at mirai-solutions.com>
> http://www.mirai-solutions.com ,
> http://miraisolutions.wordpress.com
>> J
> function (class, method, ...)
> if (nargs() == 1L && missing(method)) jclassName(class) else
> .jrcall(class,
>     method, ...)
> <environment: namespace:rJava>
>> ?J
> starting httpd help server ... done
> ===================================
>
> Here is the type of error message that I get:
>
>> source('clipboard')  # running my script
> start (1) - eval.with.vis : 08:39:25 <0.8 9.3> 9.3 : 14.6MB
> ./Puyallup Inventory - 71398292.txt 2011-12-17 17:03:48 (1) -
> f.latestFile : 08:39:25 <0.8 9.3> 9.3 : 14.6MB
> ./Puyallup Slots - 71398480.txt 2011-12-17 18:59:18 (1) - f.latestFile
> : 08:39:26 <2.2 10.8> 10.8 : 25.4MB
> Loading required package: XLConnect
> Loading required package: XLConnectJars
> Loading required package: rJava
> XLConnect 0.1-7 by Mirai Solutions GmbH <xlconnect at mirai-solutions.com>
> http://www.mirai-solutions.com ,
> http://miraisolutions.wordpress.com
> ./Puyallup Planogram Count - 72009483.txt 2012-01-13 12:51:23 (1) -
> f.latestFile : 08:39:30 <5.3 14.0> 14.0 : 24.6MB
> plano (1) - eval.with.vis : 08:39:30 <5.5 14.1> 14.1 : 26.9MB
> Loading required package: data.table
> data.table 1.7.7  For help type: help("data.table")
>
> Attaching package: ‘data.table’
>
> The following object(s) are masked from ‘package:rJava’:
>
>     J
>
> Loading required package: plyr
> Error in `[.data.frame`(x, i, j, drop) :
>   Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'character'
>
> Enter a frame number, or 0 to exit
>
>  1: source("clipboard")
>  2: eval.with.vis(ei, envir)
>  3: eval.with.vis(expr, envir, enclos)
>  4: dlply(aisle, .(div), function(.div) {
>  5: llply(.data = pieces, .fun = .fun, ..., .progress = .progress,
> .parallel = .parallel)
>  6: loop_apply(n, do.ply)
>  7: function (i)
>  8: pieces[[i]]
>  9: `[[.indexed_df`(pieces, i)
> 10: structure(x$data[x$index[[i]], , drop = FALSE], vars = x$vars)
> 11: x$data[x$index[[i]], , drop = FALSE]
> 12: `[.data.table`(x$data, x$index[[i]], , drop = FALSE)
> 13: `[.data.frame`(x, i, j, drop)
>
> Selection: 0
>>
> --
>
> I can get around it by loading 'data.table' first right now
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do it.
> _______________________________________________
> 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
>




More information about the datatable-help mailing list