[英]The nested loop is producing this error: Non-numeric argument to mathematical function
我是R的新手,無法執行此腳本。 嵌套循環輸出“數學函數的非數字參數”錯誤。 我不確定嵌套循環中的哪個參數是非數字的? 任何幫助,將不勝感激。 謝謝。
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)
最后一行應該說:
shape2<-as.numeric(shape2)
?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.