命令行R中的问题

时间:2010-08-11 02:59:17

标签: command-line r command-line-arguments command-prompt

我正在R。

中构建用户输入界面

程序的加载,我想根据一组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向用户询问一个问题,然后将响应存储在一个向量中?

1 个答案:

答案 0 :(得分:5)

请参阅?readline

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