嵌套函数:“错误:找不到嵌套函数”
我正在定义一个具有嵌套函数的函数,如下所示:
afunc <- function(p1, p2) {
for loop {
f = bfunc(p1)
}
g = cfunc(p2)
bfunc <- function(p3) {
...
}
cfunc <-function(p4){
...
}
}
出于某种原因,我收到“错误:找不到函数“bfunc””。我在这里错过了什么吗?提前致谢。
I am defining a function which has nested functions, like the following:
afunc <- function(p1, p2) {
for loop {
f = bfunc(p1)
}
g = cfunc(p2)
bfunc <- function(p3) {
...
}
cfunc <-function(p4){
...
}
}
For some reason, I am getting "ERROR: Could not find function "bfunc"". Am I missing something here? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将函数定义移至其执行位置之前:
You need to move your function definition to before where it executes: