这个问题不太可能对 future 的访客有帮助;它只与一个小的地理区域、一个特定的时刻或一个非常狭窄的情况相关,通常不适用于互联网的全局受众。如需帮助使这个问题更广泛地适用,visit the help center .
8 年前关闭。
我不明白为什么我一直收到这个错误
Error: unexpected symbol in:
" ans <- logver(theta)-logver(est)
return exp"
> }
Error: unexpected '}' in "}"
这是我的代码:
n <- 27
sum <- 30 + 28 + 26 + 22 + 26 + 27 + 25 + 18 + 34 + 33 + 20 + 25 + 27 + 33 + 31 + 27 + 21 + 30 + 26 + 24 + 30 + 33 + 17 + 28 + 21 + 30 + 27
precision<-0.1 #precision de la rejilla
intervalo<-1 #parámetro del tamaño del intervalo a graficar
logver <- function (theta) {
return -27 * theta + log (theta) * sum
}
est<- sum / n;
VR <- function (theta) { #Verosimilitud Relativa (RV)
ans <- logver(theta)-logver(est)
return exp(ans)
}
虽然,如果我删除“exp”函数调用它工作正常。
最佳答案
您没有括号 return
return(exp(ans))
关于r - "Unexpected symbol"在 R,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15192066/