错误 - 缺少参数“inputId”,没有默认值

时间:2017-06-04 15:49:01

标签: r shiny shiny-server

尝试获取数字输入并在输入上应用2个公式并使用它们绘制直方图。

用户界面

library(shiny)

shinyUI(fluidPage(
  actionButton (InputId = "USD", label = "US Bond Return"),
  actionButton (InputId = "INR", label = "Indian Bond Return"),
  numericInput(InputId = "num", label = "USD given by Investor", value = 0, 
min = 1, max = 1000, step = NA, width = NULL), plotOutput("hist")))

服务器端

library(shiny)

shinyServer(function(input, output) {

rv = reactiveValues(data = input$num)
observeEvent(input$USD, { rv$data <- (input$num * 0.0225) })
observeEvent(input$INR, { rv$data <- (input$num*0.1) })

output$curve <- renderPlot({
hist(rv$data)
})
}
)

1 个答案:

答案 0 :(得分:0)

你的用户界面有问题。它不是InputId,而是inputId(注意小i)。

因此您的ui代码如下:

shinyUI(fluidPage(
    actionButton (inputId = "USD", label = "US Bond Return"),
    actionButton (inputId = "INR", label = "Indian Bond Return"),
    numericInput(inputId = "num", label = "USD given by Investor", value = 0, 
                 min = 1, max = 1000, step = NA, width = NULL), plotOutput("hist")))