自定义 R 包加载,显示帮助但不提供功能

Custom R package loads, shows help but does not provide functions

我使用 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()

Error: could not find function "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()