R包编译依赖于data.table [英] R package compilation with dependency on data.table

查看:113
本文介绍了R包编译依赖于data.table的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用 J 的data.table创建一个带有函数的R包。
当我运行 R CMD检查,我有一个注意:没有可见的全局函数定义'J'
虽然我已经添加data.table作为DESCRIPTION文件中的依赖项。


软件包:rfPred

类型:软件包

标题:将rfPred函数预测得分分配给错义变式列表

版本:1.0

日期:2013-03-14

作者:me

维护者:我

依赖于:data.table

[..]


我试图使用data.table包中的另一个函数我想要创建的包,但我有不同于J的问题。



您是否有解决方案?

解决方案

独立函数已从 data.table 中删除​​。它只能在 DT [...] 里使用,它仍然可以工作。但对于依赖于 data.table 并正确使用 J()的包,像您的一样,需要额外的步骤避免注意(见下文)。



首先是背景,为什么 J()来自新闻的摘录:



v1.8.2(2012年7月):




  • 别名现在在DT [...]外面被废弃,但仍然在
    DT [...]中工作
    ,如在DT [J(...)]中。
    J()与程序包XLConnect(#1747)
    和rJava(#2045)中的函数J()冲突。对于data.table更改更容易,有些
    效率也更好。下一个版本的data.table将在DT [...]外部使用时从J()
    发出警告
    。之后的版本将删除它。只有
    然后将
    与rJava和XLConnect的冲突解决。
    请直接使用data.table()而不是J(),外部DT [...]。



v1.8.4(2012年11月):




  • 现在,J()现在发出警告(在 DT [...]之外使用),在DT [...]之外使用它
    已被弃用。请参阅下面v1.8.2中的项目。
    直接使用data.table()而不是使用J(),外部DT [...]。或者,
    自己定义
    别名。 J()将继续在 DT [...]中工作,因为
    已记录。



v1.8.8(现位于CRAN,2013年3月):




  • 现在在 DT [...]之外删除了J()别名,但仍然在DT [...]中工作
    ;
    ,即DT [J(...)]很好。正如在v1.8.2中警告(见下面这个
    文件)和废弃的
    在v1.8.4的warning()。这解决了与包
    XLConnect(#1747)和rJava(#2045)中的函数
    J()的冲突。
    请直接使用data.table()而不是J(),外部DT [...]。



另外,r-devel上还有一个最近的相关主题:

http://r.789695.n4.nabble.com /conflict-between-rJava-and-data-table-tp4659935p4659984.html



现在,由 R CMD检查



您的包裹正在​​使用 J() DT [...] 和工作正常。唯一的问题是来自R CMD的注释检查:

 'J'没有可见的全局函数定义



以下是所有已知的选项:




  • 忽略注释。 (我不喜欢这个,但只是作为一个选项)。

  • J 替换为列表

  • 在您的软件包中的某处定义 J = NULL 。 (我们看了 data.table 导出 J = NULL ,所以你不必, data.table 用户键入 J 将在提示符下看到 NULL

  • 或者使用?utils :: globalVariables
    b $ b


此相关问题的进一步背景:



全局变量没有可见的绑定注意在R CMD检查


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

Package: rfPred
Type: Package
Title: Assign rfPred functional prediction scores to a missense variants list
Version: 1.0
Date: 2013-03-14
Author: me
Maintainer:me
Depends: data.table
[..]

I've tried to use another function of the data.table package in the package I want to create, but I haven't the same problem as for J.

Do you have a solution ?

解决方案

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

First the background and why J() was removed. Extracts from NEWS :

v1.8.2 (Jul 2012) :

  • The J() alias is now deprecated outside DT[...], but will still work inside DT[...], as in DT[J(...)]. J() is conflicting with function J() in package XLConnect (#1747) and rJava (#2045). For data.table to change is easier, with some efficiency advantages too. The next version of data.table will issue a warning from J() when used outside DT[...]. The version after will remove it. Only then will the conflict with rJava and XLConnect be resolved. Please use data.table() directly instead of J(), outside DT[...].

v1.8.4 (Nov 2012) :

  • J() now issues a warning (when used outside DT[...]) that using it outside DT[...] is deprecated. See item below in v1.8.2. Use data.table() directly instead of J(), outside DT[...]. Or, define an alias yourself. J() will continue to work inside DT[...] as documented.

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

  • The J() alias is now removed outside DT[...], but will still work inside DT[...]; i.e., 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 function J() in package XLConnect (#1747) and rJava (#2045). Please use data.table() directly instead of J(), outside DT[...].

As an 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 produced by R CMD check on your package

Your package is using J() inside DT[...] and working fine. The only issue is the NOTE from R CMD check :

no visible global function definition for 'J'

Here are all the known options :

  • Ignore the NOTE. (I don't like this either but just as an option). Only WARNING and ERROR have to be dealt with.
  • Replace J by list. It's equivalent.
  • Define J=NULL somewhere in your package. (We looked at data.table exporting J=NULL so you wouldn't have to but decided not to since any data.table user typing J at the prompt would see NULL which may be confusing.)
  • Or use ?utils::globalVariables as Ben Bolker suggested in comments.

Further background on this particular NOTE is in this related question :

No visible binding for global variable Note in R CMD check

这篇关于R包编译依赖于data.table的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆