1

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

JelenaČuklina
  • 3,574
  • 2
  • 22
  • 35

2 Answers2

3

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
duckmayr
  • 16,303
  • 3
  • 35
  • 53
2

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__"
JelenaČuklina
  • 3,574
  • 2
  • 22
  • 35
  • Nice solution (+1). I will say that I didn't get those system variables with my solution on my machine, but overall I would still prefer your more concise/less involved approach over mine – duckmayr Jun 26 '19 at 13:48