JelenaČuklina
JelenaČuklina

Reputation: 3752

Seeking Functions in a Package not imported from other packages

I want to acquire the list of functions, defined in the package and exported, but not the ones that were imported from other packages?

The following solutions are nice, but list also function re-exported: Seeking Functions in a Package

Upvotes: 1

Views: 50

Answers (2)

JelenaČuklina
JelenaČuklina

Reputation: 3752

Actually, I found one more solution that seems to work well:

unclass(lsf.str(envir = asNamespace('myPackage')))

The benefit is that I don't get these system variables:

 "system.file"          "library.dynam.unload" ".__global__"

Upvotes: 2

duckmayr
duckmayr

Reputation: 16910

getNamespaceExports() is mentioned in one of the answers to the question you linked; luckily, there is a companion to it, getNamespaceImports(). Then we can just find the setdiff() between the two. For example:

devtools_exports <- getNamespaceExports("devtools")
devtools_imports <- getNamespaceImports("devtools")
devtools_exported_not_imported <- setdiff(devtools_exports, devtools_imports)
"install_github" %in% devtools_exports
# [1] TRUE
"install_github" %in% devtools_exported_not_imported # comes from remotes
# [1] FALSE

Upvotes: 3

Related Questions