Error: evaluation nested too deeply: infinite recursion / options(expressions=)? in R3.3.2

一曲冷凌霜 提交于 2019-12-11 09:27:29

问题


I'm trying to use a function in order to read in different models. Using the code below without a function works. When I use the function and call it, I will get the error

Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

Can anyone tell me why?

x=rnorm(1000)+sin(c(1:1000)/100)#random data+ sinus superimposed

plot <- function(model){
    par(mfrow=c(2,2))# plot window settings
    plot(model)
    lines(filter(model,rep(1/30,30)),col='red')
    plot(filter(model,rep(1/30,30)))
    plot(model-filter(model,rep(1/30,30)))

    # variances of variable, long term variability and short term variability
    var(model)
    var(filter(model, rep(1/30,30)),na.rm=T)
    var(model-filter(model, rep(1/30,30)),na.rm=T)

}

plot(x)

回答1:


The problem is that the plot function you are defining is also the one that gets called inside its body, so there is an infinite recursion here.

Rename your plot function to something else, like myplot, and you should be fine.



来源:https://stackoverflow.com/questions/49368446/error-evaluation-nested-too-deeply-infinite-recursion-optionsexpressions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!