Compiling R package with data.table dependency

I am trying to create an R package with a function using J data.table. When I run the R CMD check , I have a NOTE: there is no visible global function definition for 'J' although I added data.table as a dependency in the DESCRIPTION file.

Package: rfPred
Type: Package
Title: Assign rfPred functional forecast scores to missense options list
Version: 1.0
Date: 2013-03-14
Posted by: me
Accompanying person: me
Depends on: data.table
[..]

I tried to use another function of the data.table package in the package I want to create, but I do not have the same problem as for J.

Do you have a solution?

+8
r data.table
source share
1 answer

J() as an independent function removed from data.table . It is used only inside DT[...] , where it still works. But for packages depending on data.table and using J() correctly, like yours, an additional step is required to avoid a NOTE (see below).

Background first and why J() was removed. Excerpts from NEWS :

v1.8.2 (July 2012):

  • The alias J () is now deprecated outside of DT [...], but will still work inside DT [...], as in DT [J (...)]. J () contradicts the J () function in the package XLConnect (# 1747) and rJava (# 2045). For data.table, changing is simpler, with some efficiency benefits too. The next version of data.table will issue a warning from J () when used outside of DT [...]. After that, the version will be deleted. Only then the conflict with rJava and XLConnect will be resolved. Please use data.table () directly instead of J (), outside of DT [...].

v1.8.4 (November 2012):

  • J () now issues a warning (when used outside the DT [...]) that its use of the external DT [...] is deprecated. See clause below in v1.8.2. Use data.table () directly instead of J (), outside of DT [...]. Or, define the alias itself. J () will continue to work inside the DT [...] as documented.

v1.8.8 (now on CRAN, March 2013):

  • The alias J () is now deleted outside of DT [...], but will still work inside DT [...]; those. DT [J (...)] is fine. As warned in v1.8.2 (see below in this file) and deprecated with warning () in v1.8.4. This resolves the conflict with the J () function in the package XLConnect (# 1747) and rJava (# 2045). Please use data.table () directly instead of J (), outside of DT [...].

Aside, there was also a recent related thread on r-devel:
http://r.789695.n4.nabble.com/conflict-between-rJava-and-data-table-tp4659935p4659984.html

Now for the NOTE created by the R CMD check on your package

Your package uses J() inside DT[...] and works fine. The only problem is the NOTE from the R CMD check:

 no visible global function definition for 'J' 

Here are all the known options:

  • Ignore NOTE. (I do not like it, but as an option). Only the WARNING and the ERROR must be observed.
  • Replace J with list . It is equivalent.
  • Define J=NULL somewhere in your package. (We looked at the data.table export J=NULL , so you would not have to do this, but did not decide, since any user data.table who typed J at the invitation will see NULL , which can be misleading.)
  • Or use ?utils::globalVariables , as suggested by Bob Bolker in the comments.

Further details on this specific note relate to this related issue:

No visible binding for global variable Note in R CMD check

+9
source share

All Articles