我知道这是一个非常基本的问题,因为我是 R 的新手,我有这个问题。
如何允许用户从键盘输入数字。 为用户提供他们想要从键盘输入多少个数字,并根据该提供便利来输入数字。
例如:
How many numbers you want to enter?
> 10
Enter numbers:
> 5 10 15 20 25 30 35 40 45 50
最佳答案
while(T) {
num <- readline("How many number do you want to enter? > ")
num <- as.numeric(num)
if (!is.na(num)) {
num2 <- readline(paste0("Enter ",num, " numbers > "))
print(num2)
break
}
}
关于从R中的键盘读取输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42559094/