【问题标题】:Command line Questions in RR中的命令行问题
【发布时间】:2011-03-28 03:59:10
【问题描述】:

我正在 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 向用户提出问题,然后将响应存储在向量中?

【问题讨论】:

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


    【解决方案1】:

    ?readline

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

    【讨论】:

    • 另请参阅:menu 用于多项选择,gWidgets* 包用于图形用户界面。
    • @Richie Cotton:或者还有用于生成 GUI 的 tcltkRGtk2 包。
    • Nico:gWidgets* 环绕 tcltkRGtk2
    • @Dirk Eddelbuettel:哦,我不知道,虽然它总是第三种选择(我的错,从来没有真正看过它!:D)
    • 哇...你们太棒了。我会检查这些!
    猜你喜欢
    • 2018-03-29
    • 1970-01-01
    • 2012-09-04
    • 1970-01-01
    • 2011-08-02
    • 2020-12-29
    • 2020-12-26
    • 2010-10-01
    相关资源
    最近更新 更多