未从自制包加载的功能 [英] functions not loaded from homebuilt package
问题描述
我正在学习使用 RStudio 构建我自己的包.包(名为 SteenSubsSpec
)的当前 .tar.gz
是 此处.目前 Build &重新加载
命令似乎构建&成功对包进行 Roxygen 化.然而,尽管 Build & 事实上,这些函数似乎并没有被加载到内存中.Reload
成功更新了文档.我做错了什么?
I'm learning to build my own packages using RStudio. The current .tar.gz
for the package (named SteenSubsSpec
) is here. Currently the Build & Reload
command appears to build & Roxygen-ize the package successfully. However, the functions do not appear to be loaded into memory, despite the fact Build & Reload
successfully updates the documentation. What am I doing wrong?
构建&重新加载
给出以下输出:
==> roxygenize('.', roclets=c('rd'))
- 正在检查更改...完成
==> R CMD 构建 SteenSubsSpec
==> R CMD build SteenSubsSpec
* checking for file ‘SteenSubsSpec/DESCRIPTION’ ... OK
* preparing ‘SteenSubsSpec’:
* checking DESCRIPTION meta-information ... OK
* excluding invalid files
Subdirectory 'R' contains invalid file names:
‘2013_08_30_report-concordance.tex’ ‘2013_08_30_report.Rnw’
‘2013_08_30_report.log’ ‘2013_08_30_report.pdf’
‘2013_08_30_report.synctex.gz’ ‘2013_08_30_report.tex’
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
Removed empty directory ‘SteenSubsSpec/inst’
* building ‘SteenSubsSpec_1.0.tar.gz’
Source package written to ~/Dropbox/[my directory]
这会更新文档:?write_paper()
按预期显示当前文档.不过
This updates the documentation: ?write_paper()
displays the current documentation as expected. However
require(SteenSubsSpec)
write_paper()
给出错误:找不到函数write_paper"
有些事情似乎是正确的:
Some things that seem to be correct:
- 所有的函数文件都在
R
目录下,并且与它们的定义同名(例如/R/write_paper.R
定义了write_paper() <- 函数 {...
DESCRIPTION
文件包含所有相关函数文件的名称:Collate: ... 'write_paper.R
- All function files are in the
R
directory, and have the same name as their definition (e.g/R/write_paper.R
defineswrite_paper() <- function {...
- The
DESCRIPTION
file contains the names of all the relevant function files:Collate: ... 'write_paper.R
我该如何解决这个问题?
How can I troubleshoot this?
推荐答案
很可能,这些函数没有导出到 NAMESPACE 文件(您声明该文件当前为空).
Most likely, the functions are not exported to the NAMESPACE file (which you state is currently empty).
在 RStudio 中,在项目选项"中的构建工具"下,确保选中使用 roxygen 生成文档".然后,单击配置".确保使用 roxygen 生成 NAMESPACE 文件"也被选中.
In RStudio, under "build tools" in "project options", make sure that "Generate documentation with roxygen" is checked. Then, click on "configure". Make sure that "Use roxygen to generate NAMESPACE file" is also checked.
在你的 R 函数文件中,添加一个 @export yourfunctionname
(或者,技术上,一个 #' @export yourfunctionname
),当你构建和重新加载时,您的 NAMESPACE 文件应该更新,您的函数应该不再不可见.
In your R function files, add an @export yourfunctionname
in there (or, technically, an #' @export yourfunctionname
), and when you build and reload, your NAMESPACE file should be updated and your functions should no longer be invisible.
这篇关于未从自制包加载的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!