您如何知道R中的哪些功能已标记为调试? [英] how do you know which functions in R are flagged for debugging?
本文介绍了您如何知道R中的哪些功能已标记为调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我现在更经常使用 debug()
,但是有时我想知道哪些功能已标记为调试。我知道您可以使用 isdebugged()
来查找是否标记了特定功能。但是,R是否有办法列出所有正在调试的功能?
I've been using debug()
more often now, but sometimes I wonder which functions have been flagged for debugging. I know that you can use isdebugged()
to find out if a particular function is flagged. But is there a way for R to list all the functions that are being debugged?
推荐答案
这很麻烦,但可以:
find.debugged.functions <- function(environments=search()) {
r <- do.call("rbind", lapply(environments, function(environment.name) {
return(do.call("rbind", lapply(ls(environment.name), function(x) {
if(is.function(get(x))) {
is.d <- try(isdebugged(get(x)))
if(!(class(is.d)=="try-error")) {
return(data.frame(function.name=x, debugged=is.d))
} else { return(NULL) }
}
})))
}))
return(r)
}
您可以像这样在所有环境中运行它:
You can run it across all your environments like so:
find.debugged.functions()
或者就在您的 .GlobalEnv中:
Or just in your ".GlobalEnv" with this:
> find.debugged.functions(1)
function.name debugged
1 find.debugged.functions FALSE
2 test TRUE
在这里,我创建了一个正在调试的测试函数。
Here I created a test function which I am debugging.
这篇关于您如何知道R中的哪些功能已标记为调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文