gpt4 book ai didi

从R中的键盘读取输入

转载 作者:行者123 更新时间:2023-12-02 03:06:20 25 4
gpt4 key购买 nike

我知道这是一个非常基本的问题,因为我是 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com