简体   繁体   English

在R包中包含数据集

[英]Including a dataset in a R package

This question may seem pretty naive and I bag your patience. 这个问题似乎很幼稚,我耐心等待。

I have saved extension.RData and documented it in extension.R . 我已经保存了extension.RData并将其记录在extension.R Both of them are saved in /data folder of the R package I am developing. 它们都保存在我正在开发的R包的/data文件夹中。

As I close RStuidio and reload the package, however, I cannot call the data until I execute one of the functions, devtools::document() or devtool::load_all() . 但是,当我关闭RStuidio并重新加载程序包时,我必须执行devtools::document()devtool::load_all()函数之一,才能调用数据。 Does this suggest that my dataset is not in memory of the package? 这是否表明我的数据集不在包的内存中? How could I not to execute devtools every time I start working on the package? 每次开始处理软件包时,如何不执行devtools

Thank you very much. 非常感谢你。

As I have understood, you just created files extension.RData , extension.R (with documentation) in your project directory. 据我了解,您刚刚在项目目录中创建了文件extension.RDataextension.R (带有文档)。 However, this is not enough for RStudio to be able to reach your data. 但是,这还不足以使RStudio能够访问您的数据。 You have to install the package by running devtools::install() or clicking 'Build & Reload' button on 'Build' tab of RStudio. 您必须通过运行devtools::install()或在RStudio的“构建”选项卡上单击“构建并重新加载”按钮来安装软件包。

Edit : Putting extension.R into R folder solves the problem. 编辑 :将extension.R放到R文件夹中可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM