親愛的所有人,我想輸入一個整數交互到R然後捕獲它並在我的代碼中使用它。我正在用scan()函數嘗試它,但它給了我錯誤! 這是我做了什麼:如何在R中交互輸入一個整數
#This is my question
print("enter a positive integer")
n <- scan()
while(is.numeric(n) == F){
print("enter a positive integer")
n <- scan()
}
此外,第一線的執行後,我希望程序暫停對我來說,輸入n它檢查while循環
#This part is not part of my question; after capturing n I would want to use it in a code like this.
c <- ncol(d)
r <- nrow(d)
for(i in 1:c) {
d[n,i] <- 0
}
多前感謝所有可以幫助的人。 艾薩克·奧烏蘇
韋恩你好,非常感謝。它同樣適用 – 2011-05-03 19:50:01