无法从R中的命名空间导出数据 [英] Data not exported from namespace in R

查看:159
本文介绍了无法从R中的命名空间导出数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在笔记本电脑上根据Hadley关于Devtools,Roxygen2等的大量文档,设置了R包并将其定期更新到GitHub。昨天我决定改用我的主PC,现在希望将更改推送到GitHub。输入 document()后出现以下错误:

I've set up and been regularly updating my R package to GitHub following Hadley's extensive documentation about Devtools, Roxygen2 etc., on my laptop. Yesterday I decided to use my main PC instead and am now looking to push changes up to GitHub. I got the following error after entering document() :

Error: 'Adult_Females' is not an exported object from 'namespace:gbm.auto'

Adult_Females是/ Data中第一个数据文件的名称。根据(向下滚动到数据)

Adult_Females is the name of the first data file in /Data. According to this (scroll down to 'Data')

驻留在数据中的文件/不使用通常的命名空间机制,也不需要导出。

"files that live in data/ don’t use the usual namespace mechanism and don’t need to be exported."

所以...去做?我没有以任何方式编辑Adult_Females,并且我编辑的R脚本没有引用它。我怀疑是所有数据文件都会弹出此错误,而这恰好是它们中的第一个,但这是一个推测。

So... what's a guy to do? I've not edited Adult_Females in any way and the R script I edited doesn't reference it. My suspicion is that this error will pop up for all the data files and it just happened that this is the first of them, but that's conjecture at this point.

在此先感谢您。 install_github( SimonDedman / gbm.auto)如果您想看看。

Thanks in advance. install_github("SimonDedman/gbm.auto") if you want to have a look.

2020/01/25编辑:看起来我已经解决了。在19/11/26提交时,看到/ Data和所有RData文件已添加,随后的提交删除了相同的/ data文件夹和文件。不确定我是否自己做过,不知道为什么我会突然决定这样做,但是这样的谜团现在已被时光迷失了。此更改以及document()和commit导致从NAMESPACE中将.R文件作为export()删除,而RData文件不再触发标题为未导出的数据。问题即使在DESCRIPTION,NAMESPACE或文件本身中也没有指出。也许这怪异性会成为灯塔,向其他人发出我过去三年被困在岩石上的警告!

2020/01/25 edit: looks like I've fixed it. A commit on 26/11/19 saw /Data and all RData files added, with subsequent commit deleting the identical /data folder and files. Not sure if I did that myself, can't think why I would suddenly decide to, but such mysteries are now lost to the sands of time. This change and document() and commit caused the .R files to be removed as export()s from NAMESPACE and the RData files to no longer trigger the titular "data not exported" problem EVEN THOUGH this isn't noted anywhere in DESCRIPTION, NAMESPACE, nor the files themselves. May this weirdness be a lighthouse that warns others of the rock I've spent the last 3 years trapped on!

推荐答案

编写包含数据集的R包时,也会遇到类似的问题。我猜您必须将数据集保存为其他名称。

I encountered a similar problem when writing an R package which contains a dataset. I guess you must have saved the dataset in a different name.

例如,您可以这样写:

devtools:::use_data(YourDataSetName, pkg = "Path_to_Pkg/data", internal = FALSE)

,但是在您的 data.R 文件中,您在而不是 YourDataSetName (假设您在这里遵循了Hadley的指示: http ://r-pkgs.had.co.nz/data.html )。

but in your data.R file, you specified a dataset name at the very end other than YourDataSetName (suppose you followed Hadley's instructions here: http://r-pkgs.had.co.nz/data.html).

确保保存到 data文件夹中的数据对象与您在 data.R 文件中指定的相同。

Make sure the data object you saved to the "data" folder is the same as you specified in your data.R file.

注意: use_data 现在是 usethis 包。

这篇关于无法从R中的命名空间导出数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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