R Packaging中的inst和extdata文件夹 [英] inst and extdata folders in R Packaging
问题描述
在文档中,R建议将原始数据文件(不是Rdata或Rda)放置在inst/extdata/
In the documentation, R suggests that raw data files (not Rdata nor Rda) should be placed in inst/extdata/
在以下第一段中: http: //cran.r-project.org/doc/manuals/R-exts.html#Data-in-packages
data子目录用于数据文件,使其可用 通过延迟加载或使用data()加载. (由 Description文件中的"LazyData"字段:默认为不执行 这样.)不应将其用于程序包所需的其他数据文件, 惯例已经成长为使用目录inst/extdata来实现 文件.
The data subdirectory is for data files, either to be made available via lazy-loading or for loading using data(). (The choice is made by the ‘LazyData’ field in the DESCRIPTION file: the default is not to do so.) It should not be used for other data files needed by the package, and the convention has grown up to use directory inst/extdata for such files.
因此,我已将所有原始数据移动到该文件夹中,但是当我生成并重新加载程序包,然后尝试使用(例如)以下函数访问数据时:
So, I have moved all of my raw data into this folder, but when I build and reload the package and then try to access the data in a function with (for example):
read.csv(file=paste(path.package("my_package"),"/inst/extdata/my_raw_data.csv",sep=""))
# .path.package is now path.package in R 3.0+
我收到无法打开文件"错误.
I get the "cannot open file" error.
但是,它看起来确实像在软件包目录中有一个名为/extdata
的文件夹,其中包含文件(生成后和安装). /inst
文件夹怎么了?
However, it does look like there is a folder called /extdata
in the package directory with the files in it (post-build and install). What's happening to the /inst
folder?
/inst文件夹中的所有内容是否都推送到软件包的/
中?
Does everything in the /inst folder get pushed into the /
of the package?
推荐答案
你们俩都很亲密,本质上就是这样. "Writing R Extensions"的正式参考是:
You were both very close and essentially had this. A formal reference from 'Writing R Extensions' is:
1.1.3包子目录
1.1.3 Package subdirectories
[...]
inst
子目录的内容将被递归复制
到安装目录. inst
的子目录不应
干扰R使用的那些(当前是R
,data
,demo
,
exec
,libs
,man
,help
,html
和Meta
和早期版本
使用latex
,R-ex
). inst
的复制发生在src
之后
内置,因此其Makefile
可以创建要安装的文件.先于
在R 2.12.2中,这些文件已安装在具有包源权限的POSIX平台上,因此应注意确保
这些不太严格:R CMD build
将使适合
调整.要排除文件安装,可以指定一个
顶级文件.Rinstignore
中的排除模式列表
源目录.这些模式应该像Perl一样
表达式(有关详细信息,请参见R中regexp
的帮助),
每行一个,与文件和目录路径匹配(10),
例如doc/.*[.]png$
将基于以下原因排除inst/doc
中的所有PNG文件
(小写)扩展名.
The contents of the inst
subdirectory will be copied recursively
to the installation directory. Subdirectories of inst
should not
interfere with those used by R (currently, R
, data
, demo
,
exec
, libs
, man
, help
, html
and Meta
, and earlier versions
used latex
, R-ex
). The copying of the inst
happens after src
is built so its Makefile
can create files to be installed. Prior to
R 2.12.2, the files were installed on POSIX platforms with the permissions in the package sources, so care should be taken to ensure
these are not too restrictive: R CMD build
will make suitable
adjustments. To exclude files from being installed, one can specify a
list of exclude patterns in file .Rinstignore
in the top-level
source directory. These patterns should be Perl-like regular
expressions (see the help for regexp
in R for the precise details),
one per line, to be matched(10) against the file and directory paths,
e.g. doc/.*[.]png$
will exclude all PNG files in inst/doc
based on
the (lower-case) extension.
这篇关于R Packaging中的inst和extdata文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!