[英]The nested loop is producing this error: Non-numeric argument to mathematical function
I'm very new to R and I'm having trouble executing this script. 我是R的新手,无法执行此脚本。 The nested loop outputs a "Non-numeric argument to mathematical function" error. 嵌套循环输出“数学函数的非数字参数”错误。 I'm not sure which argument in the nested loop is non-numerical? 我不确定嵌套循环中的哪个参数是非数字的? Any help on this would be greatly appreciated. 任何帮助,将不胜感激。 Thanks. 谢谢。
library(emdbook)
prev<-read.delim("shape.txt", header=T)
shape1<-prev$shape1
shape1<-as.numeric(shape1)
shape2<-prev$shape2
shape1<-as.numeric(shape2)
pvec <- seq(0, 1, length=298)
postvec<-data.frame(posterior=1:298)
dim(postvec)
for (i in 1:length(shape1))
{
for (j in 1:length(shape2))
{
postvec[i]<- dbeta(pvec, shape1= shape1[i], shape2=shape2[j])
}
}
prev<-read.delim("shape.txt", header=T)
shape1<-prev$shape1
shape1<-as.numeric(shape1)
shape2<-prev$shape2
shape1<-as.numeric(shape2)
Should that last line say: 最后一行应该说:
shape2<-as.numeric(shape2)
? ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.