Reputation: 13
I am trying to create a R shiny App for my data visualization. The data looks like
ID route_id trip_id direction boarding alighting load
192197 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 68 0 167
192198 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 4 0 171
192199 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 4 0 175
192200 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 1 0 176
192201 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 3 0 179
192202 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 9 0 188
192203 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 0 0 188
192204 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 1 0 189
192205 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 1 0 190
192206 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 0 0 190
192207 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 1 0 191
192208 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 0 0 191
192209 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 4 0 195
192210 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 0 0 195
192211 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 3 0 198
192212 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 14 0 212
192213 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 0 23 189
192214 760-76 8223726-MAR15-MVS-BUS-Weekday-01 Southbound_760__Express_/_Downtown 0 27 162
194205 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 15 0 154
194206 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 0 0 154
194207 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 0 0 154
194208 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 0 0 154
194209 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 0 0 154
194210 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 0 0 154
194211 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 0 0 154
194212 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 15 0 169
194213 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 0 0 165
194214 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 1 4 166
194215 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 0 0 166
194216 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 1 0 167
194217 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 3 0 170
194218 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 0 7 163
194219 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 0 2 161
194220 589-76 8224010-MAR15-MVS-BUS-Weekday-01 Northbound_589__Express_/_Minneapolis 0 9 152
313432 852-76 8227043-MAR15-MVS-BUS-Weekday-01 Southbound_852__Express_/_Northtown_/_Dntn_Mpls 21 0 151
313433 852-76 8227043-MAR15-MVS-BUS-Weekday-01 Southbound_852__Express_/_Northtown_/_Dntn_Mpls 0 0 151
313434 852-76 8227043-MAR15-MVS-BUS-Weekday-01 Southbound_852__Express_/_Northtown_/_Dntn_Mpls 0 0 151
313435 852-76 8227043-MAR15-MVS-BUS-Weekday-01 Southbound_852__Express_/_Northtown_/_Dntn_Mpls 6 0 157
313616 852-76 8227045-MAR15-MVS-BUS-Weekday-01 Southbound_852__Express_/_Northtown_/_Dntn_Mpls 53 0 183
313617 852-76 8227045-MAR15-MVS-BUS-Weekday-01 Southbound_852__Express_/_Northtown_/_Dntn_Mpls 0 0 183
313618 852-76 8227045-MAR15-MVS-BUS-Weekday-01 Southbound_852__Express_/_Northtown_/_Dntn_Mpls 0 0 183
313619 852-76 8227045-MAR15-MVS-BUS-Weekday-01 Southbound_852__Express_/_Northtown_/_Dntn_Mpls 9 0 192
313620 852-76 8227045-MAR15-MVS-BUS-Weekday-01 Southbound_852__Express_/_Northtown_/_Dntn_Mpls 0 24 168
325301 21-76 8227241-MAR15-MVS-BUS-Weekday-01 Westbound_21__Selby-Lake/_Uptown 18 0 160
325302 21-76 8227241-MAR15-MVS-BUS-Weekday-01 Westbound_21__Selby-Lake/_Uptown 2 0 162
325303 21-76 8227241-MAR15-MVS-BUS-Weekday-01 Westbound_21__Selby-Lake/_Uptown 0 0 162
325304 21-76 8227241-MAR15-MVS-BUS-Weekday-01 Westbound_21__Selby-Lake/_Uptown 6 7 161
325305 21-76 8227241-MAR15-MVS-BUS-Weekday-01 Westbound_21__Selby-Lake/_Uptown 6 2 165
325306 21-76 8227241-MAR15-MVS-BUS-Weekday-01 Westbound_21__Selby-Lake/_Uptown 5 2 168
325307 21-76 8227241-MAR15-MVS-BUS-Weekday-01 Westbound_21__Selby-Lake/_Uptown 18 12 174
325308 21-76 8227241-MAR15-MVS-BUS-Weekday-01 Westbound_21__Selby-Lake/_Uptown 4 5 169
325309 21-76 8227241-MAR15-MVS-BUS-Weekday-01 Westbound_21__Selby-Lake/_Uptown 0 4 169
325310 21-76 8227241-MAR15-MVS-BUS-Weekday-01 Westbound_21__Selby-Lake/_Uptown 0 0 169
352204 94-76 8227923-MAR15-MVS-BUS-Weekday-01 Westbound_94_Express_/_Downtown_/_Minneapolis 55 0 155
352398 94-76 8227934-MAR15-MVS-BUS-Weekday-01 Westbound_94_Express_/_Downtown_/_Minneapolis 52 0 170
352399 94-76 8227934-MAR15-MVS-BUS-Weekday-01 Westbound_94_Express_/_Downtown_/_Minneapolis 0 11 159
352400 94-76 8227934-MAR15-MVS-BUS-Weekday-01 Westbound_94_Express_/_Downtown_/_Minneapolis 0 2 157
352674 94-76 8227949-MAR15-MVS-BUS-Weekday-01 Westbound_94_Express_/_Downtown_/_Minneapolis 37 0 162
352675 94-76 8227949-MAR15-MVS-BUS-Weekday-01 Westbound_94_Express_/_Downtown_/_Minneapolis 0 10 152
390699 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 48 1 164
390700 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 2 0 166
390701 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 3 0 169
390702 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 3 1 171
390703 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 171
390704 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 4 0 175
390705 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 16 0 191
390706 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 191
390707 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 12 0 203
390708 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 1 0 204
390709 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 4 11 197
390710 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 197
390711 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 7 4 200
390712 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 1 3 198
390713 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 1 197
390714 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 187
390715 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 6 10 193
390716 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 2 1 194
390717 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 194
390718 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 2 184
390719 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 8 184
390720 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 9 175
390721 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 1 0 176
390722 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 176
390723 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 3 4 165
390724 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 10 165
390725 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 2 163
390726 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 2 161
390727 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 2 159
390728 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 159
390729 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 3 153
390730 22-76 8270934-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 3 153
390817 22-76 8270935-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 11 0 158
390818 22-76 8270935-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 158
390819 22-76 8270935-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 158
390820 22-76 8270935-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 158
390821 22-76 8270935-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 2 0 160
390822 22-76 8270935-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 160
390823 22-76 8270935-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 160
392402 22-76 8270947-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 20 0 170
392403 22-76 8270947-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 170
392404 22-76 8270947-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 8 162
392405 22-76 8270947-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 162
392406 22-76 8270947-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 3 159
392407 22-76 8270947-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 159
392408 22-76 8270947-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 159
392409 22-76 8270947-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 152
392410 22-76 8270947-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 7 152
392411 22-76 8270947-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 152
392412 22-76 8270947-MAR15-MVS-BUS-Weekday-01 Southbound_22H__Cedar-28Av/VA_Med_Ctr/Via_Dupont-57 0 0 152
415001 17-76 8339808-MAR15-MVS-BUS-Weekday-01 Eastbound_17__Downtown 27 0 169
415002 17-76 8339808-MAR15-MVS-BUS-Weekday-01 Eastbound_17__Downtown 0 0 169
415003 17-76 8339808-MAR15-MVS-BUS-Weekday-01 Eastbound_17__Downtown 0 5 164
415004 17-76 8339808-MAR15-MVS-BUS-Weekday-01 Eastbound_17__Downtown 3 0 167
415005 17-76 8339808-MAR15-MVS-BUS-Weekday-01 Eastbound_17__Downtown 0 0 167
415006 17-76 8339808-MAR15-MVS-BUS-Weekday-01 Eastbound_17__Downtown 0 0 167
415007 17-76 8339808-MAR15-MVS-BUS-Weekday-01 Eastbound_17__Downtown 0 0 167
415008 17-76 8339808-MAR15-MVS-BUS-Weekday-01 Eastbound_17__Downtown 0 0 167
415009 17-76 8339808-MAR15-MVS-BUS-Weekday-01 Eastbound_17__Downtown 0 0 166
415010 17-76 8339808-MAR15-MVS-BUS-Weekday-01 Eastbound_17__Downtown 0 1 166
422541 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 35 0 160
422542 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 0 1 159
422543 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 2 0 161
422544 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 34 0 195
422545 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 3 0 198
422546 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 2 5 195
422547 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 0 6 189
422548 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 1 0 190
422549 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 1 3 188
422550 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 0 0 187
422551 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 0 1 187
422552 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 0 1 184
422553 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 2 2 186
422554 17-76 8339910-MAR15-MVS-BUS-Weekday-01 Eastbound_17W__Wash_St_NE_/_To_27th_NE 0 30 156
441158 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 49 0 153
441159 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 5 0 158
441160 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 0 0 158
441161 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 3 0 161
441162 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 0 0 161
441163 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 0 0 161
441164 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 1 0 162
441165 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 0 0 162
441166 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 0 0 162
441167 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 0 0 162
441168 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 0 0 162
441169 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 0 0 162
441170 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 0 0 162
441171 724-76 8346221-MAR15-MVS-BUS-Weekday-01 Southbound_724_Brklyn_Ctr_/_Transit_Ctr 0 0 162
So the following is my ui.R The file takes input from the user for route_id, and then creatw bar graph for eg. load for various stop_id.
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')
)
)
)
and my server.R is follwing
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,sum)
})
output$plot1 <- renderPlot({barplot(a[input$rider])})
}
Every time I run this app. i get the following error:
object of type 'closure' is not subsettable
I am new in creating R shiny app. Please help
Upvotes: 1
Views: 177
Reputation: 13128
Try rewriting server.R
in the following way:
server <- function(input, output, session) {
# Combine the selected variables into a new data frame
data <- reactive({
subset(y, route_id == input$route,
select = c('route_id', input$id, input$rider))
})
a <- reactive({
aggregate(as.formula(paste0(input$rider, "~", input$id)), data(), sum)
})
output$plot1 <- renderPlot({
barplot(a()[,input$rider])
})
}
Explanation. There are several problems with the code, but as far as I can tell, the problem that gives rise to your error message is that you did not specify your reactive functions (e.g. data
, a
) with parentheses, e.g. in your calls to aggregate
and barplot
.
Another error is that you call aggregate
using the formula construct, but input$rider~input$id
is actually something like "boarding"~"trip_id"
, rather than boarding~trip_id
. I amended this using as.formula(paste0(...))
.
Third, barplot
takes a vector or matrix for its height
argument, but using a()[input$rider]
gives you a dataframe; instead, use a()[, input$rider]
(with the comma).
Fourth, in your ui.R
, you have a stop_id
option, but this column doesn't actually exist in your dataframe. I didn't change it since it produces a warning but does not kill your app.
Fifth, note that you can filter and select columns with a single call to subset
.
You should get an output like this:
Upvotes: 0