您如何确定函数的名称空间? [英] How do you determine the namespace of a function?

查看:42
本文介绍了您如何确定函数的名称空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出一个函数,如何确定它来自哪个命名空间?

Given a function, how do you determine which namespace it has come from?

例如,如果我在命令提示符下键入mean.default,则输出将包含它在基本软件包中的事实.我希望能够执行类似getNamespace(mean.default)的操作并使它返回基本"(或实际的基本环境).

For example, if I type mean.default at the command prompt, the output includes the fact that it is in the base package. I want to be able to do something like getNamespace(mean.default) and have it return "base" (or the actual base environment).

有一个getNamespace函数,但似乎只接受程序包名称,而不是函数名称.

There is a getNamespace function but seems to only accept package names rather than function names.

print.function使用内部代码来检索名称空间.我可以在src/main/print.c中浏览do_printfunction,但是后来放弃了.

print.function uses internal code to retrieve the namespace. I got as far as browsing do_printfunction in src/main/print.c but then gave up.

推荐答案

我最近了解到find()似乎就是这样做的.

I very recently learned about find() which seems to do just this.

R> find("ls")
[1] "package:base"
R> find("na.locf")
[1] "package:zoo"

这篇关于您如何确定函数的名称空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆