简体   繁体   中英

Object not found after installing and loading package

I've thrown together a bunch of my utility functions into a package. However, I can't seem to access them after I've installed the package. I get errors of the form Error: object 'function_name' not found

  1. Building the package, there are no error messages
  2. Installing the package from source, there are no error messages
  3. Loading the package, there are no error messages (library() nor require())
  4. The package documentation is accessible once loaded
  5. I'm using roxygen2 to generate documentation and the namespace

Any thoughts?

Do you use a NAMESPACE and forgot to add the object in question?

If you're using roxygen2, have you remembered to add #' @export function_name to the functions you want included in the namespace?

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

pkgname:::function_name

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

The same problem for me, you need to change NAMESPACE file. sometime NAMESPACE's content looks like this:

# Generated by roxygen2: do not edit by hand

But you need to change it by hand , like this:

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

OR use exportPattern("^[^\\\\.]") to export all function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM