排除与R包构建的数据集 [英] Exclude data sets from R package build

查看:122
本文介绍了排除与R包构建的数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实施的R包,在那里我有在数据文件夹中的几大.rda数据文件。

I'm implementing an R package, where I have several big .rda data files in the 'data' folder.

当我建立包(有R CMD建立创建.tar.gz格式压缩文件),也将数据文件都包含在该程序包,因为他们是真正的大,这使得构建(以及检查)的过程很慢,最终的封装尺寸白白大了。

When I build the package (with R CMD build to create the .tar.gz packed file), also the data files are included in the package, and since they are really big, this makes the build (as well the check) process very slow, and the final package size uselessly big.

这些数据从一些数据库通过封装的函数下载,所以意图不是包括在包中的数据,而是让用户填充从其自己的数据库中的数据的文件夹。我使用的数据是试验,这是没有意义的就包括进包中。

These data are downloaded from some DB through a function of the package, so the intent is not to include the data in the package, but to let the user populates the data folder from its own DB. The data that I use are for test, and it makes no sense to include them into the package.

总结我的问题是:是否有可能保持数据的数据文件夹,但是从构建的程序包中排除

修改

好吧,我发现了一个解决方案,首先通过创建一个名为 .Rbuildignore 包含行:

Ok, I found a first solution by creating a file named .Rbuildignore that contains a line:

^data/.+$

反正问题仍然存在对R CMD安装和R CMD检查过程中,没有考虑到 .Rbuildignore 文件。

任何建议排除一个文件夹还从安装/检查流程?

Any suggestion to exclude a folder also from the install/check processes?

推荐答案

如果您使用 .Rbuildignore 你应该先建再检查你的包(它不是一个检查忽略)。在这里,在一个Debian环境中的一些测试和随机包:

If you use .Rbuildignore you should first build then check your package (it's not a check-ignore). Here a few tests in a Debian environment and a random package:

l@np350v5c:~/src/yapomif/pkg$ ls
data  DESCRIPTION  man  NAMESPACE  R

l@np350v5c:~/src/yapomif/pkg$ R
> save(Formaldehyde, file = "data/formal.rda")

l@np350v5c:~/src/yapomif/pkg$ ls -l
totale 20
drwxr-xr-x 2 l l 4096 mag  1 01:31 data
-rw-r--r-- 1 l l  349 apr 25 00:35 DESCRIPTION
drwxr-xr-x 2 l l 4096 apr 25 01:10 man
-rw-r--r-- 1 l l 1189 apr 25 00:33 NAMESPACE
drwxr-xr-x 2 l l 4096 apr 25 01:02 R

l@np350v5c:~/src/yapomif/pkg$ ls -l data/
totale 4
-rw-r--r-- 1 l l 229 mag  1 01:31 formal.rda

现在我确切地创建你的 .Rbuildignore

Now i create exactly your .Rbuildignore

l@np350v5c:~/src/yapomif/pkg$ em .Rbuildignore
l@np350v5c:~/src/yapomif/pkg$ cat .Rbuildignore
^data/.+$

好吧,让我们建立

Ok let's build

l@np350v5c:~/src/yapomif/pkg$ cd ..
l@np350v5c:~/src/yapomif$ R CMD build pkg
> tools:::.build_packages()
* checking for file ‘pkg/DESCRIPTION’ ... OK
* preparing ‘yapomif’:
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
Removed empty directory ‘yapomif/data’
* building ‘yapomif_0.8.tar.gz’

精细(你看到yapomif /数据的消息)。现在,检查包

Fine (you see the message about yapomif/data). Now check the package

l@np350v5c:~/src/yapomif$ R CMD check yapomif_0.8.tar.gz
> tools:::.check_packages()
* using log directory ‘/home/l/.src/yapomif/yapomif.Rcheck’
* using R version 3.1.0 (2014-04-10)
* using platform: x86_64-pc-linux-gnu (64-bit)
...

......一切都像往常一样

... everything as usual

现在让我们来检查文件(移动到主目录,以保持我
发展清洁DIR)

Now let's check the file (moved to home directory to keep my development dir clean)

l@np350v5c:~/src/yapomif$ mv yapomif_0.8.tar.gz ~
l@np350v5c:~/src/yapomif$ cd
l@np350v5c:~$ tar xvzf yapomif_0.8.tar.gz
l@np350v5c:~$ ls yapomif
DESCRIPTION  man  NAMESPACE  R

,所以没有数据目录

so there is no data directory

但如果

l@np350v5c:~/src/yapomif$ R CMD check pkg

...

Undocumented data sets:
  ‘Formaldehyde’

因此​​,如前所述,第一个构建,然后检查。

So, as stated, first build, then check.

HTH,卢卡

这篇关于排除与R包构建的数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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