navbarPage not creating a menu in Shiny

Hi!

I'm new to using Shiny

Can anyone tell me why when I run this app, I only see one page. Shouldn't navbarPage() create three tabs: Overview, Map, and Plots?

Am I missing a step somewhere?

library(shiny)

county.education <- as.data.frame(structure(list(X.1 = 1:20, X = 1:20, countyfips = c(1001L, 1005L, 
1011L, 1017L, 1021L, 1025L, 1033L, 1035L, 1037L, 1039L, 1041L, 
1047L, 1049L, 1053L, 1059L, 1061L, 1065L, 1071L, 1077L, 1091L
), statefips = c(1L, 2L, 3L, 4L, 6L, 7L, 8L, 12L, 13L, 14L, 17L, 
18L, 20L, 22L, 23L, 24L, 26L, 27L, 28L, 29L), County = c("Autauga County", 
"Barbour County", "Bullock County", "Chambers County", "Chilton County", 
"Clarke County", "Colbert County", "Conecuh County", "Coosa County", 
"Covington County", "Crenshaw County", "Dallas County", "DeKalb County", 
"Escambia County", "Franklin County", "Geneva County", "Hale County", 
"Jackson County", "Lauderdale County", "Marengo County"), State = c("AL", 
"AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", 
"AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL"), control.ppe = c(5963, 
6759.4150390625, 7041.32080078125, 6948.86884045997, 6688.623046875, 
6811.24560546875, 8044.0244145212, 7191.7548828125, 6968, 6682.14297733142, 
6839.056640625, 6958.24473344, 6856.33204638119, 7584.90576171875, 
7411.71728515625, 6656.64760945396, 6945.24560546875, 7664.54736328125, 
8634.1513671875, 6949.57283682865), ppe.growth = c(752.889248934659, 
1101.14311079545, 1338.57177734375, 608.185358615382, 520.846812855114, 
746.869096235795, 748.457553101724, 1785.57594992898, 1164.73983487216, 
1030.79406880416, 694.161088423295, 948.600777952231, 905.654853529151, 
395.732199928977, 422.813387784091, 739.112646699455, 969.758567116477, 
992.287863991477, 1464.17009943182, 804.354194280363), control.grad.rate = c(90L, 
83L, 86L, 87L, 87L, 89L, 89L, 88L, 89L, 87L, 90L, 88L, 80L, 83L, 
82L, 84L, 84L, 88L, 89L, 86L), outcome.grad.rate = c(80L, 61L, 
73L, 80L, 73L, 78L, 76L, 78L, 48L, 77L, 88L, 71L, 86L, 77L, 85L, 
77L, 67L, 80L, 81L, 87L), student.body = c(9327.90909090909, 
2926.09090909091, 1798, 5314, 7213.90909090909, 1622.90909090909, 
8467.09090909091, 1879.63636363636, 1538.72727272727, 6312.09090909091, 
2413.36363636364, 8643.27272727273, 11116.4545454545, 1326.81818181818, 
2380.90909090909, 4017, 3207.45454545455, 2728.72727272727, 4213.54545454545, 
4015.45454545455), student.body.growth = c(415.909090909091, 
-198.909090909091, -155, -277, 550.909090909091, -13.0909090909091, 
-48.9090909090909, -265.363636363636, -196.272727272727, -276.909090909091, 
83.3636363636364, -614.727272727273, 951.454545454545, -47.1818181818182, 
15.9090909090909, -188, -131.545454545455, -107.272727272727, 
-343.454545454545, -100.545454545455), income.growth = c(0.250052987306596, 
0.082293702089283, 0.131121495327103, 0.00380265530240944, 0.156493313521545, 
0.139033897125357, 0.116892888313721, 0.135075792762741, 0.162701329947203, 
0.16882786676837, 0.164710184677272, 0.085952533675433, 0.0910991732878695, 
0.0864142077257964, 0.149853569034261, 0.144803155357534, 0.141060606060606, 
0.0518489591156238, 0.148801128349788, 0.135673556664291), county.growth = c(26.4, 
-5.7, -6, -4.1, 8.3, -2.3, 1.4, -2.9, 2.4, -0.7, 1.3, -4.4, 6.9, 
-1, 0.2, 4.2, -2.2, -0.5, 7.2, -2.6), adult.education = c(18, 
10.9, 7.7, 9.5, 9.9, 12.1, 14.1, 9.2, 8, 12.2, 11.2, 13.9, 8.3, 
10.6, 9.7, 8.7, 8.1, 10.4, 18.5, 12.1), partisanship = c(0.00239306261986159, 
0.0287096774193548, 0.0482903000697837, 0.0078681464303462, 0.00315914961255712, 
0.00726452905811623, 0.00465868035748241, 0.0185624305298259, 
0.0193534844668346, 0.00363798683182681, 0.0144289294665235, 
0.00807065217391304, 0.00271302720823263, 0.00556272401433692, 
0.00705997712044452, 0.00440194292653309, 0.0201742627345845, 
0.00597050147492625, 0.00247167868177137, 0.0107462686567164), 
    new.outcome = c(-10L, -22L, -13L, -7L, -14L, -11L, -13L, 
    -10L, -41L, -10L, -2L, -17L, 6L, -6L, 3L, -7L, -17L, -8L, 
    -8L, 1L)), row.names = c(NA, 20L), class = "data.frame")

ui <- fluidPage(navbarPage(title="Capstone Project 2019",
                           header="Erica Grabowski",
                           footer="Data collected for my senior capstone project at New York University's Sociology Department."),
                tabPanel("Overview", "To be continued..."),
                tabPanel("Map", "To be continued..."),
                tabPanel("Plots", 
                         titlePanel("Plot1"),
                         sidebarLayout(
                           sidebarPanel(
                             sliderInput(inputId = "bins",
                                         label = "Scale",
                                         min = 8,
                                         max = 160,
                                         value = 100)),
                           mainPanel(
                             plotOutput(outputId = "distPlot")))))
                
server <- shinyServer(function(input, output){
  output$distPlot <- renderPlot({
    
    x    <- county.education$ppe.growth
    x    <- na.omit(x)
    bins <- seq(min(x), max(x), length.out = input$bins + 1)
    
    hist(x, breaks = bins, col = "#75AADB", border = "black",
         xlab = "Change in Per Pupil Expenditures",
         main = "School Spending Growth 2010-2016")
})
})

shinyApp(ui, server)

Thanks in advance!

It looks like you closed the parentheses for navbarPage() too early. If you refer to the function documentation here, you can see that tabPanel elements belong inside the parentheses. Your UI should look like this:

ui <- fluidPage(navbarPage(title="Capstone Project 2019",
                           header="Erica Grabowski",
                           footer="Data collected for my senior capstone project at New York University's Sociology Department.",
                tabPanel("Overview", "To be continued..."),
                tabPanel("Map", "To be continued..."),
                tabPanel("Plots"), 
                         titlePanel("Plot1"),
                         sidebarLayout(
                           sidebarPanel(
                             sliderInput(inputId = "bins",
                                         label = "Scale",
                                         min = 8,
                                         max = 160,
                                         value = 100)),
                           mainPanel(
                             plotOutput(outputId = "distPlot")))))
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

thank you!
this solved it