R Shiny CRUD应用程序上的单选按钮问题

时间:2018-05-28 10:34:44

标签: r shiny

我正在构建一个调查,我在github上引用这个Shiny CRUD app,这个工作正常,直到我有一个带单选按钮的问题。

UI中的

有一个新的输入字段

radioButtons("Question1","Question1", choices = c("Y","N","NA"),inline=T),

我更改了以下CRUD功能,以适应上述输入字段

    # Cast from Inputs to a one-row data.frame
    CastData <- function(data) {
      datar <- data.frame(name = data["name"], 
                          used_shiny = as.logical(data["used_shiny"]), 
                          r_num_years = as.integer(data["r_num_years"]),
                          Question1 = data["Question1"],
                          stringsAsFactors = FALSE)

      rownames(datar) <- data["id"]
      return (datar)
    }

    # Return an empty, new record
    CreateDefaultRecord <- function() {
      mydefault <- CastData(list(id = "0", name = "", Question1 = "Y",used_shiny = FALSE, r_num_years = 2))
      return (mydefault)
    }

    # Fill the input fields with the values of the selected record in the table
    UpdateInputs <- function(data, session) {
      updateTextInput(session, "id", value = unname(rownames(data)))
      updateTextInput(session, "name", value = unname(data["name"]))
      updateCheckboxInput(session, "used_shiny", value = as.logical(data["used_shiny"]))
updateRadioButtons(session, "Question1",value = unname(data["Question1"]))
      updateSliderInput(session, "r_num_years", value = as.integer(data["r_num_years"]))
    }

当我运行时,我收到错误“警告:updateRadioButtons中的错误:未使用的参数(value = unname(data [”Question1“]))” 无法解决此问题

1 个答案:

答案 0 :(得分:0)

radioButtons没有任何名为value的参数您可能想要使用selected

希望这有帮助!