从R中调用命名空间获取局部变量

从R中调用命名空间获取局部变量,r,R,我希望能够从调用的函数中从R检索局部变量。我能做这个吗?(如构建调试器。)示例: show\u locals这有什么帮助吗@nico:它可能会涉及这个函数,但它只提供直接上下文中的局部变量,而不是调用上下文中的局部变量。 show_locals <- function() # put something in here that shows local_1 and its value local_1 = 123 show_locals() # inspect local varia

我希望能够从调用的函数中从R检索局部变量。我能做这个吗?(如构建调试器。)示例:


show\u locals这有什么帮助吗@nico:它可能会涉及这个函数,但它只提供直接上下文中的局部变量,而不是调用上下文中的局部变量。
show_locals <- function()
  # put something in here that shows local_1 and its value

local_1 = 123
show_locals()  # inspect local variables with custom formatting
show_locals <- function() ls(parent.frame())
print(get('local_1'), parent.frame())