【发布时间】:2018-03-19 06:00:06
【问题描述】:
我正在尝试从闪亮的滑块中获取输入,并通过调用其上的函数来在服务器部分中使用它来获取图形信息。但是,来自滑块的输入在服务器端无法识别,并引发错误。
评估错误:缺少参数“小时”,没有默认值。
inputID 与参数匹配,所以我不明白为什么它无法访问它。
library(shiny)
library(shinydashboard)
get_data <- function(foo){return(foo)}
#build shiny app
header <- dashboardHeader(
title="Data"
)
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Charts and Analysis", tabName = "charts", icon = icon("bar-chart-o"),
menuSubItem("Temperature by Time of Day", tabName = "temperatures", icon = NULL) )
)
)
body <- dashboardBody(
tabItems(
tabItem(tabName = "temperatures",
fluidRow(
box(
title = "Time of Day",
sliderInput(inputId = "hour", label="Hour (military)", min=0, max=23, value=12, step=1)
),
box(plotOutput("series"))
)
)
)
)
ui <- dashboardPage(skin="green", header, sidebar, body)
server <- function(input, output) {
MR <- get_data(strtoi(input$hour))
output$series <- renderPlot({
plot(x=MR, y=MR)
})
}
shinyApp(ui, server)
【问题讨论】:
标签: r shiny shinydashboard