在新环境中存储功能,显示功能详细信息
Store function in a new environment, show function details
我正在研究是否可以将所有 "user-defined-functions" 存储在一个环境(而不是全局环境)中。我设法创建环境并在环境内发送函数。我也可以参考[environment$function].
调用函数
但是,我无法获取函数的详细信息。
问题:如何查看位于环境中的函数的详细信息?
我的代码:
# Create environment.
env_functions <- new.env()
# Create function, send in to above mentioned environment.
env_functions$my_print <- function() {
print("hello")
}
预期此命令应显示函数的详细信息:
ls.str(env_functions)
结果:
my_print : function ()
# 为什么看不到函数的详细信息?
但是可以调用函数:
env_functions$my_print()
结果:
[1] "hello"
没有理由不使用只输入函数名的标准方式,如果你想查看函数的定义:
env_functions$my_print
function ()
{
print("hello")
}
我正在研究是否可以将所有 "user-defined-functions" 存储在一个环境(而不是全局环境)中。我设法创建环境并在环境内发送函数。我也可以参考[environment$function].
调用函数但是,我无法获取函数的详细信息。
问题:如何查看位于环境中的函数的详细信息?
我的代码:
# Create environment.
env_functions <- new.env()
# Create function, send in to above mentioned environment.
env_functions$my_print <- function() {
print("hello")
}
预期此命令应显示函数的详细信息:
ls.str(env_functions)
结果:
my_print : function ()
# 为什么看不到函数的详细信息?
但是可以调用函数:
env_functions$my_print()
结果:
[1] "hello"
没有理由不使用只输入函数名的标准方式,如果你想查看函数的定义:
env_functions$my_print
function ()
{
print("hello")
}