如何在R中修复“无功能可返回,跳至顶级”?

时间:2019-06-29 14:33:07

标签: r function

当我在函数下面运行时,它返回错误“无功能可返回,跳到顶层”

由于函数似乎结构正确,我似乎无法找到错误。

所有定义的参数都是根据TTM(值列表)而改变的,除了到期日更改。

您能帮助我理解错误消息吗?

Condor_strategy <- function (TTM) {

    result = c()
        for (i in 1:length(TTM)){

        maturity = TTM[i]

        a = MCAsianOptionPricer(maturity, K2,spot, stdv, Rf, 0, 0, 1, 10000, maturity * 365)
        b = MCAsianOptionPricer(maturity,K4, spot, stdv, Rf, 0, 1, 1, 10000, maturity * 365)
        c = MCAsianOptionPricer(maturity, K1,spot, stdv, Rf, 0, 1, 1, 10000, maturity * 365)
        d = MCAsianOptionPricer(maturity, K3, spot stdv, Rf, 0, 1, 1, 10000, maturity * 365)

        result = append(result, a-b-c-d)

        }
    return(result)
}


> dput(head(TTM))
c(0.004, 0.008, 0.012, 0.016, 0.02, 0.024)


Error in append(result, a - b - c - d) : object 'a' not found
>         
>         }
Error: unexpected '}' in "        }"
>     return(result)
Error: no function to return from, jumping to top level
> }
Error: unexpected '}' in "}"
> 

0 个答案:

没有答案