【发布时间】:2016-10-21 21:35:25
【问题描述】:
我正在尝试使用 R Shiny 创建图形应用程序。因此,我从用户那里获取路线、停止/旅行 ID(登机、下车或装载)的输入。所以 ui.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 创建条形图。 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
请帮我解决这个问题。我是闪亮的新手。
【问题讨论】: