从 R 包构建中排除数据集

编程入门 行业动态 更新时间:2024-10-22 23:49:19
本文介绍了从 R 包构建中排除数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在实现一个 R 包,其中的data"文件夹中有几个大的 .rda 数据文件.

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

当我构建包时(使用 R CMD build 创建 .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 文件.

anyway the problem remains for the R CMD install and R CMD check processes, that do not take into account the .Rbuildignore file.

有什么建议将文件夹也排除在安装/检查过程之外吗?

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

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

好的,让我们构建

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/data 的消息).现在检查包装

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) ...

...一切如常

现在让我们检查文件(移动到主目录以保存我的开发目录干净)

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

所以没有数据目录

如果

l@np350v5c:~/src/yapomif$ R CMD check pkg ... Undocumented data sets: ‘Formaldehyde’

因此,如上所述,首先构建,然后检查.

So, as stated, first build, then check.

HTH,卢卡

更多推荐

从 R 包构建中排除数据集

本文发布于:2023-11-16 17:02:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1606178.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中排   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!