Package Prefix double-colon notation in user-created package

Our team created a user-defined R package for a project. When we created this package, we did so on a Windows OS and included the name of the package we built as a prefix whenever we call one of its R functions (e.g., dplyr::filter()). However, now that our RStudio server is hosted in Linux as opposed to the Windows environment that it was in previously, I'm running into an error trying to call the package functions with the prefix included:

Table_A1 <- package_name::Table_A1func(year,  data)
Error: 'Table_A1func' is not an exported object from 'namespace:package_name'

However, when I remove the package name prefix, it runs as expected.

Table_A1 <- Table_A1func(year, data)

This only seems to be an issue with the R package we built and not with any other packages we call in from CRAN. Please note that we are using devtools to develop the package and we're using R 3.5.0. We are not able to update to a more recent version of R due to project requirements. We'd like to be able to retain the use of the package prefix for two reasons:

  1. Ensure there are no namespace conflicts with other packages in case functions have the same name;
  2. Avoid going through hundreds of scripts that use the package prefix as this method was integrated throughout all the scripts in our package.

Thank you!

In an environment where calling Table_A1func(year, data) works, can you call Table_A1func w/o the parenthesis? this should output something like

function (year, data)
{
    [actual code]
}
<bytecode: ....>
<environment: ....>

The last line tells you from which environment it comes, i.e. this would read namespace:package_name if it came from there. What does it say in your case?

You can also use

library(package_name)
ls(name="package:package_name)

to list all exports from that package. Does that contain Table_A1func?

Hi! After running Table_A1func without the parenthesis, the last line reads <environment: namespace:package_name>. Table_A1func also appears in the list of exports after running ls(name="package:package_name").

Figured out a solution: using triple colons instead of double colons. It seems that, for some reason, the functions are not recognized as being exported from our package. Just noting this here in case it helps others!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.