Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
354 views
in Technique[技术] by (71.8m points)

r - Calling a function from a namespace

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'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...