Re: [R] Function that works within a package and not when copied in global environment. Why?

2017-02-02 Thread William Dunlap via R-help
When searching for the object referred to by a name, R looks first in the current environment, then in the environment's parent environment, then in that environment's parent environment, etc. It stops looking either when the name is found or when it hits .EmptyEnv, the ultimate ancestor of all

Re: [R] Function that works within a package and not when copied in global environment. Why?

2017-02-02 Thread Bert Gunter
OK. Try: nlWaldTest:::vectorize.args (3 colons) Your error message said it was *not* exported, so you need 3 colons (which, in general, is a bad idea.It's usually not exported for a reason). I presume vectorize.args is is in the environment of the function copied from the name space, because

Re: [R] Function that works within a package and not when copied in global environment. Why?

2017-02-02 Thread Marc Girondot via R-help
Thanks Bert for the explanation about identical. For the vectorize.args, note that vectorize.args is not a function but an variable that is unknown in the namespace nlWaldTest. > nlWaldTest::vectorize.args Erreur : 'vectorize.args' n'est pas un objet exporté depuis 'namespace:nlWaldTest'

Re: [R] Function that works within a package and not when copied in global environment. Why?

2017-02-02 Thread Bert Gunter
1. No they're not. e.g. > f <- function() NULL > g <- function()NULL > identical(f,g) [1] FALSE > str(f) function () - attr(*, "srcref")=Class 'srcref' atomic [1:8] 1 6 1 20 6 20 1 1 .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' > str(g) function () - attr(*, "srcref")=Class

[R] Function that works within a package and not when copied in global environment. Why?

2017-02-02 Thread Marc Girondot via R-help
Dear experts, In the package nlWaldTest, there is an hidden function : .smartsub I can use it, for example: > getFromNamespace(".smartsub", ns="nlWaldTest")(pat="x", repl="b" , x="essai(b[1], b[2], x[1])") [1] "essai(b[1], b[2], b[1])" Now I try to create this function in my global