Object not found after installing and downloading a package

I put together a bunch of my utility functions in a package. However, I cannot access them after I installed the package. I get errors of the form Error: object 'function_name' not found

  • Build package, error messages
  • Install package from source, no error messages
  • Download package, no error messages (library () and require ())
  • Package documentation available after download
  • I use roxygen2 to create documentation and namespace

Any thoughts?

+4
source share
3 answers

Are you using NAMESPACE and forgot to add this object?

If you use roxygen2, did you remember adding #' @export function_name to the functions you want to include in the namespace?

+5
source

If the function name is not exported, you may need to use ":"

 pkgname:::function_name 

I believe CRAN now requires NAMESPACE, and I think that R 2.14.x may even require them.

+3
source

Same for me, you need to modify the NAMESPACE file. sometimes the contents of NAMESPACE are as follows:

# Generated by roxygen2: do not edit by hand

But you need to change it manually, for example:

 # Generated by roxygen2: do not edit by hand export("function_name1", "function_name2") 

OR use exportPattern("^[^\\.]") To export all functions.

0
source

Source: https://habr.com/ru/post/1380035/


All Articles