is_from_namespace: Check whether a function, environment comes from a namespace

is_from_namespaceR Documentation

Check whether a function, environment comes from a namespace

Description

A coarse way to find if a function comes from a package.

Usage

is_from_namespace(x, recursive = TRUE)

Arguments

x

function, environment, language (with environment attached)

recursive

whether to recursively search parent environments

Value

logical true if x or its environment is defined in a namespace; returns false if the object is atomic, or defined in/from global environment, or an empty environment.

Examples



is_from_namespace(baseenv())        # TRUE
is_from_namespace(utils::read.csv)  # TRUE

x <- function(){}
is_from_namespace(NULL)             # FALSE
is_from_namespace(x)                # FALSE
is_from_namespace(emptyenv())       # FALSE

# Let environment of `x` be base environment
# (exception case)
environment(x) <- baseenv()
is_from_namespace(x)        # TRUE



dipsaus documentation built on June 27, 2024, 5:10 p.m.