在 R 中创建内部函数(无法从控制台调用)

2024-01-21

我正在开发一个 R 包,其中有一个生成一些文件的总体函数,我们将其称为main(...)它存在于自己的文件中main.R. Now main调用其他函数,例如helper1(...) and helper2(...)发现于helper1.R and helper2.R。是否有可能做到这一点main可以调用辅助函数,但用户不能直接调用辅助函数?由于它们的用途存在明显差异,我将它们分散在不同的文件中。将它们全部放在一个文件下的解决方案main.R?


Read R 包 http://r-pkgs.had.co.nz/作者:哈德利·威克姆。

What you want is should be the default behaviour for packages: you have exported and non-exported functions. Unless you explicitly declare a function as exported, it is invisible to the outside and only usable by other functions inside the package.

所以你不需要为辅助函数做任何事情。但是,您确实需要标记main功能与导出一样。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 R 中创建内部函数(无法从控制台调用) 的相关文章

随机推荐