I'm trying to alter the functionality of a few commands in a package in R. It's easy enough to see the source of the commands. However the function calls other functions that are in the package namespace. These functions are not exported objects. So how can I access them?
Specific example:
How would I access the asCall() function that is used in copula::rmvdc?
require(copula) copula::rmvdc getAnywhere("asCall")
so as.Call()
exists in the copula package, but how do I access it?
> copula::asCall Error: 'asCall' is not an exported object from 'namespace:copula'
Namespaces in C++ You only need to prefix the function you wish to call with namespace_name:: -- similar to how you would call a static member function of a class. Another convenience of namespaces is that they allow you to use the same function name, when it makes sense to do so, to perform multiple different actions.
A namespace is a declarative region that provides a scope to the identifiers (the names of types, functions, variables, etc) inside it. Namespaces are used to organize code into logical groups and to prevent name collisions that can occur especially when your code base includes multiple libraries.
The statement using namespace std is generally considered bad practice. The alternative to this statement is to specify the namespace to which the identifier belongs using the scope operator(::) each time we declare a type. Example 1: CPP.
using namespace std; are used. It is because computer needs to know the code for the cout, cin functionalities and it needs to know which namespace they are defined.
Try this:
copula:::asCall
This was previously answered on R-help. That function was not exported in the package namespace, so you need to use the :::
operator instead. Typically functions are not exported when they are not intended for general usage (e.g. you don't need to document them in this case).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With