我有一個寫在Basic上的腳本,它獲取輸入CSV文件並計算輸入數據隨機分割之間的衝突。這個腳本是here。我需要在R上重新實現它。我寫了such腳本。 Here是輸入數據。調試R腳本
但條件
if(nentries==nrows*ncolumns)
{
print("Columns, rows, and entries check; we're good to go.")
}
else
{
print("Columns, rows, and entries don't check; please look at your data file to make sure each line has equal no. of entries.")
}
出現錯誤
source("path\\to\\script.r")
error in source("path\\to\\script.r") :
D:\projects\basicToR\target.r:19:1: Unexpected 'else'
18: }
19: else
^
爲什麼是錯誤嗎? R文件中是否還有其他錯誤?
UPDATE 我忘了寫在問題有關錯誤seq.default
錯誤(1,firstsofar,1): '通過' 的說法
中的代碼片段
無效 跡象for (q in seq(1,firstsofar,1)) {
if(randnum[i]==randnum[q]) {taken="yes"}
}
至於你的編輯,它是完全無關你的原始問題,所以要得到答案,你應該開始一個新的問題。但是這聽起來像'firstsofar'取小於1的值,所以你給出的第三個參數'by = 1'是錯誤的符號(正數,而不是負數)以獲得序列。 – Gregor