【问题标题】:Custom R package loads, shows help but does not provide functions自定义 R 包加载,显示帮助但不提供功能
【发布时间】:2017-11-20 09:39:59
【问题描述】:

我使用devtools 创建的自定义包安装、加载、显示功能的帮助文件,但不提供功能。 This solution 似乎不相关,因为我的包安装在 .libPaths() 中。

# from the parent directory of the created package
install.packages("mypkg", repos = NULL, type = "source")
# ...
# * DONE (mypkg)
require(mypkg)
# Loading required package: mypkg
?my.fun        # displays the function help documentation correctly
my.fun()

错误:找不到函数“my.fun”

是什么导致了这种行为以及如何解决它?

sessionInfo()
#R version 3.3.0 (2016-05-03)
#Platform: x86_64-apple-darwin13.4.0 (64-bit)
#Running under: OS X 10.13.1 (unknown)

#locale:
#[1] cs_CZ.UTF-8/cs_CZ.UTF-8/cs_CZ.UTF-8/C/cs_CZ.UTF-8/cs_CZ.UTF-8

#attached base packages:
#[1] stats     graphics  grDevices utils     datasets  methods   base     

#other attached packages:
#[1] mypkg_0.1    devtools_1.13.4

#loaded via a namespace (and not attached):
#[1] tools_3.3.0   withr_2.1.0   memoise_1.0.0 git2r_0.19.0  digest_0.6.9 

【问题讨论】:

  • 你导出函数了吗?要检查它是否在包中运行:mypkg:::my.fun()
  • @trosendal 谢谢!是的,就是这样。在我的函数中错过了@export 标签。如果您将评论更改为答案,我将提供信用。

标签: r devtools r-package


【解决方案1】:

你导出函数了吗?要检查它是否在包中运行:

mypkg:::my.fun()

【讨论】:

  • 我在函数头中添加了#' @export,它起作用了。感谢您注意到这一点。
猜你喜欢
  • 2011-11-06
  • 1970-01-01
  • 1970-01-01
  • 2014-08-15
  • 2021-02-23
  • 1970-01-01
  • 1970-01-01
  • 2016-01-01
  • 1970-01-01
相关资源
最近更新 更多