亲爱的所有人,我想输入一个整数交互到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