【问题标题】:How to check if an environment is a package namespace [duplicate]如何检查环境是否是包命名空间[重复]
【发布时间】:2018-03-10 23:08:51
【问题描述】:

我正在寻找一种方法来检测环境是否是包命名空间。期望的行为:

is.namespace(environment(data.frame))
## [1] TRUE
is.namespace(environment(ggplot2::ggplot))
## [1] TRUE
is.namespace(globalenv())
## [1] FALSE
is.namespace(new.env(parent = globalenv()))
## [1] FALSE

【问题讨论】:

  • ??我认为您的代码中有错字。应该是is.namespace(environment(ggplot2::ggplot))

标签: r namespaces r-environment


【解决方案1】:

原来有这样的功能。但由于我不明白的原因,它被命名为isNamespace 而不是is.namespace

> isNamespace(environment(data.frame))
[1] TRUE

更多信息也可以在这里的相关问题中找到:How to distinguish package namespace environment from other environment objects

【讨论】:

    猜你喜欢
    • 2011-02-06
    • 1970-01-01
    • 2013-09-10
    • 1970-01-01
    • 1970-01-01
    • 2012-07-14
    • 1970-01-01
    • 1970-01-01
    • 2018-04-04
    相关资源
    最近更新 更多