[英]R showed an error message when create a variable in a loop
我用Tinn-R編寫程序。 當我使用source()在R中運行它時,顯示錯誤消息。 以下示例僅包括部分循環。
for (nn in 1:length(nSim)) ##whether the right loop???
{
r.all <- c()
p.final <- array(0, c(15,5)) #1-5 a, b1, b2, b3, b4; 6 group id
r.reference <- cbind(GRM_sim(t(p.sample[,1]), t(p.sample[,2:5]),sample.all[iS],0,rep(1,sample.all[iS]))
DIF_ID <-c()
DIF_index <- rep(0,15)
for (iC in 1:length(CDIF))
{
if (CDIF[iC]==1)
{
DIF_ID <- sample(1:15,DIF.all[iDIF.all]) ##consistent DIF
}
for (id in 1:length(DIF_ID))
{
DIF_index[DIF_ID[id]] <-1
}
...
source(“ 120413consistentMH.R”)中的錯誤:120413consistentMH.R:107:17:意外符號106:
107:DIF_ID
謝謝你的時間。
該錯誤是缺少括號的典型錯誤。 讓自己的編輯器與parens匹配,或者學會更自由地使用空格和回車符。 滾動到該頁面末尾的第五行缺少右括號:
r.reference <- cbind(GRM_sim( t( p.sample[,1] ),
t( p.sample[,2:5]),
sample.all[iS],0,
rep(1, sample.all[iS])
)
^
missing paren here
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.