如何定义从包导出的变量或函数 [英] How to define which variables or functions from a package are exported

查看:176
本文介绍了如何定义从包导出的变量或函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的R包使用内部变量 x 。如果我加载包(我只尝试使用 devtools :: load_all ),那么 x 不会显示在 ls()列表中,但它确实有一个值。我如何避免这种情况?

My R package uses an internal variable x. If I load the package (I've only tried using devtools::load_all), then x doesn't appear in the ls() list, but it does have a value. How can I avoid this?

我很好,用户可以使用 myPackage :: x ,但不是简单的 x

I'm fine with the user being able to access the variable with myPackage::x, but not simply x.

推荐答案

load_all 函数有一个 export_all 参数。

?load_all


如果为TRUE(默认),导出所有对象。如果为FALSE,则只导出在NAMESPACE文件中列为导出的对象。

If TRUE (the default), export all objects. If FALSE, export only the objects that are listed as exports in the NAMESPACE file.

所以,尝试使用您的 load_all 呼叫中的export_all = FALSE

So, try using export_all=FALSE in your load_all call.

这篇关于如何定义从包导出的变量或函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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