Re: [R] How to get the namespace of a function?

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Fri 03 Feb 2006 - 07:43:23 EST

On 2/2/2006 10:56 AM, Fernando Saldanha wrote:
> I declared the environment of the function myfun to be NULL as follows:
>
> environment(myfun) <- NULL

Since version 2.1.0, it's been recommended that you use

environment(myfun) <- baseenv()

and since 2.2.0, you'll get a warning when using NULL (and you'll get an error in 2.3.0). But why would you want to do that? What are you trying to achieve?

Duncan Murdoch

>
> Later on I called that myfun and got an error message because the
> function index() in the zoo package was called inside myfun and was
> not visible:
>
> Error in myfun(args) : couldn't find function "index"
>
> I tried to use zoo::index() instead of index(), but that did not work.
> In fact, zoo::index does not work even in the command line:
>

>> z<-ts(1:5)
>> z

> Time Series:
> Start = 1
> End = 5
> Frequency = 1
> [1] 1 2 3 4 5
>> index(z)

> [1] 1 2 3 4 5
>> zoo::index(z)

> Error in loadNamespace(name) : package 'zoo' does not have a name space
>
> How can I qualify index() so that it is visible inside the body of myfun?
>
> Thanks for any suggestions,
>
> FS
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Feb 03 07:50:51 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:19 EST