首页 > 解决方案 > 警告:$ 中的错误:“闭包”类型的对象不是子表 75:唯一

问题描述

我正在制作一个 R 闪亮的应用程序,但我遇到了以下问题:当我启动我的应用程序时,会显示一条错误消息:

警告:$ 中的错误:“闭包”类型的对象不是子表 75:单个

我做了研究,发现它可能来自括号问题,但我不知道在哪里。

这是我的代码:

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")

                )


            )
        )
    )
))

标签: rshiny

解决方案


推荐阅读