R 中的命令行问题

发布于 2024-09-13 23:47:27 字数 555 浏览 5 评论 0原文

我正在程序的 R.onload 中构建一个用户输入界面

,我想根据一组 6 个字段询问用户他们的偏好是什么。然后,这将用作程序其余部分的比较工具。

例如,

>ThisProgram  
>"Hello, on a scale of 1 to 10, how much would you say you rate the outdoors in your trips?    Enter a 10 for very important, and a 1 for not important at all.   
>7  
>"Great. on a scale of 1 to 10, how much would you say you rate the Family Friendly in your  trips?  Enter a 10 for very important, and a 1 for not important at all. 
>2
  .
  .
  .
  and so on...

我如何让 R 向用户提问,然后将响应存储在向量中?

I am building an user input interface in R.

onload of the program, I would like like to ask the user what their preferences are according to a set of 6 fields. This will then be used as a comparison tool for the rest of the program.

e.g.,

>ThisProgram  
>"Hello, on a scale of 1 to 10, how much would you say you rate the outdoors in your trips?    Enter a 10 for very important, and a 1 for not important at all.   
>7  
>"Great. on a scale of 1 to 10, how much would you say you rate the Family Friendly in your  trips?  Enter a 10 for very important, and a 1 for not important at all. 
>2
  .
  .
  .
  and so on...

how would I get R to ask the user a question, and then store the response in a vector?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏辞 2024-09-20 23:47:27

请参阅 ?readline

> x <- readline("What is your name? ")
What is your name? Josh
> x
[1] "Josh"

See ?readline

> x <- readline("What is your name? ")
What is your name? Josh
> x
[1] "Josh"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文