1
我正在嘗試使用R閃亮創建圖形應用程序。因此,我從用戶那裏接受來自用戶的路線,停車/旅行ID(登機,下車或載重)的輸入。所以ui.r是「閉包」類型的對象不可子集:R閃亮應用程序
ui <- fluidPage(
pageWithSidebar(
headerPanel('FAST_TRIPS Visulization', windowTitle = "Fast_trips Visaualization"),
sidebarPanel(
selectInput('route', 'Choose the Route No.', unique(y['route_id'])),
selectInput('id', 'Please Choose Stop or Trip ID', c('stop_id','trip_id')),
selectInput('rider', 'What do you wanna compare?', c('boarding', 'alighting', 'load')),
radioButtons('method','Please select your method', c('Sum', 'Average'))),
mainPanel(
plotOutput('plot1')
)
)
)
然後我試圖提取特定的路線,例如用stop_id登機,並試圖爲那些stop_id一個barplot合計值的數據。該server.R低於
server <- function(input, output, session) {
# Combine the selected variables into a new data frame
selectedData <- reactive({
y[c('route_id', input$id, input$rider)]
})
data <- reactive({
subset(selectedData, route_id == input$route)
})
a <- reactive({
aggregate(input$rider~input$id,data,input$method)
})
s <- reactive({input$rider})
output$plot1 <- renderPlot({barplot(a[s])})
}
但我收到以下錯誤:
Error: object of type 'closure' is not subsettable
請幫助我。我是新來的閃亮。