2

I am making an R shiny application, but I encountered the following problem: when I launch my application, an error message is displayed:

Warning: Error in $: object of type 'closure' is not subsettable 75: single

I did research and I saw that it could come from a problem of parenthesis but I do not see where.

Here is my code:

shinyServer(function(input, output) {

    ## Table DATA
    output$table.pop <-renderDataTable(
        data,
        server=T,
        options=list(dom= 'tp', #table + pagination
                     pageLength = 25 ,
                     orderClasses=T
        )
    )

    ## Graphique Stat Global
    output$distPlot <- renderPlot({

        x    <- data$age
        bins <- seq(min(x), max(x), length.out = 5)

        hist(x, breaks = bins, col = '#FF6600', border = 'white',main ="Répartition de l'âge ")

    })

    output$barplot <- renderPlot({
        x <- table(data$Catlib)
        barplot(x,col ="purple",border = "white",main="Effectif par catégorie",las=2)
    })

    ## Graphique par sport
    output$distPlot1 <- renderPlot({
        data <- data[data$FedNom == input$select,]
        x    <- data$age
        bins <- seq(min(x), max(x), length.out = 5)
        hist(x, breaks = bins, col = '#FF6600', border = 'white',main ="Répartition de l'âge")

    })

    output$barplot1 <- renderPlot({
       data <- data[data$FedNom == input$select,]
        x <- table(data$Catlib)
        barplot(x,col ="purple",border = "white",main="Effectif par catégorie",las=2)
    })

    ## Carte 
    output$mymap <- renderLeaflet({
      leaflet() %>% 
        addProviderTiles(providers$Stamen.TonerLite,
                         options = providerTileOptions(noWrap = TRUE)
        ) %>% 
        addCircleMarkers(
          lng = data1$Longitude, 
          lat = data1$Longitude, 
          radius = data1$NB, weight = 0.25, 
          stroke = T, opacity = 100,
          fill = T, fillColor = "#920000", 
          fillOpacity = 100,
          popup = ctry$label,
          color = "red") 
    })
})


shinyUI(fluidPage(
    dashboardPage(
        dashboardHeader(title="Sportifs de haut niveau en 2015"),
        dashboardSidebar(
            sidebarMenu(
                menuItem("Table", tabName = "table",icon = icon("table")),
                menuItem("Statistique Descriptive", tabName = "plot"),
                menuItem("Carte",tabName = "carte")

            )
        ),
        dashboardBody(
            tabItems(
                ## Feuille data
                tabItem(tabName="table",
                        h3("Table"),
                        DT::dataTableOutput("table.pop")
                ),

                ## Feuille Stats desc

                tabItem(tabName="plot",
                        fluidRow(
                            h3("Statistique Descriptives Global")),br(),
                        fluidRow(column(6,
                            box(plotOutput("distPlot", height = 500))),
                                column(6,
                            box(plotOutput("barplot", height = 500)))),
                        fluidRow(
                            h3("Statistique Descriptives par sport")),br(),
                        fluidRow(
                            selectInput("select",label = h3("Selectionnez le sport de votre choix"), choices = unique(data$FedNom), selected= unique(data$FedNom)[1])),br(),
                        fluidRow(column(6,
                            box(plotOutput("distPlot1", height = "500px"))),
                            column(6,
                            box(plotOutput("barplot1", height = "500px"))))

                ),

                ### Carte 
                tabItem(tabName="carte",
                        leafletOutput("mymap")

                )


            )
        )
    )
))
Allan Cameron
  • 147,086
  • 7
  • 49
  • 87
  • Hi, StackOverflow is a place to answer questions but also share the answers and questions so that other people may benefit from them. Moreover, you will receive more help by asking questions in a language that most people understand. Therefore, you should translate your post in English (use ```deepl.com``` if you are not comfortable in English) – bretauv Mar 19 '20 at 16:22
  • what is `data`? where did you define it? you may want to check [here](https://stackoverflow.com/a/24240693/11598948) – bretauv Mar 19 '20 at 16:57
  • data c'est mon data frame,qui est défini juste au dessus mais je l'ai pas copié dans le code – Axel Lozach Mar 20 '20 at 12:29
  • Well we can't run your app if we don't have the data. Use `dput` on a subset of your data to generate the code for it – bretauv Mar 20 '20 at 12:31

0 Answers0