【问题标题】:R Shiny: Error Navbarpage Argument is missing with no default, shiny RR Shiny:错误导航栏页参数丢失,没有默认值,闪亮的 R
【发布时间】:2020-11-27 15:37:55
【问题描述】:

我对闪亮的 R 相当陌生,我对它的格式感到很困扰。我不知道如何组织它更清洁。我觉得我已经检查了所有内容,但是我不知道我错过了什么。它一直给我 ErrorNavbarPage 参数丢失,没有默认值!我的代码哪里错了?谢谢

ui <- fluidPage(
  navbarPage(title = "Demo Bar",
             tabPanel("Percent college",
                      sidebarLayout(
                        sidebarPanel(
                          selectInput(inputId = "state", label = "Select a state:",
                                      choices = unique(midwest$state),
                                      selected = "IL",
                                      multiple = TRUE),
                          hr(),
                          helpText("Data From Midwest data frame"),
                          textInput(inputId = "title", label = "Write a title!", value = "Midwest scatter plot comparison")
                        ),
                        mainPanel(
                          plotlyOutput(outputId = "scatterplot")
                        ),
                      ),
             ),
             tabPanel("Data Page",
                      sidebarLayout(
                        sidebarPanel(
                          sliderInput(
                            inputId = "area_choice",
                            label = "Range of Area",
                            min = area_range[1],
                            max = area_range[2],
                            value = area_range
                          ),
                        ),
                          mainPanel(
                            plotOutput("plot")
                          ),
                      ),
             ),
  ),
)

【问题讨论】:

  • 你有很多多余的逗号。只要是最后一个元素,您就需要删除 ","
  • 我不太明白你的意思是什么抱歉。你能指出哪里可能有多余的逗号吗?
  • 请去掉mainPanel( plotOutput("plot") )后面的所有逗号,即ui后面的四个逗号不需要。
  • 上帝保佑你!你真的很有帮助!现在我明白我有太多多余的逗号了!哈哈哈这些东西到处都是!

标签: r shiny shinyapps


【解决方案1】:

没有额外逗号的工作代码:

ui <- fluidPage(
  navbarPage(
    title = "Demo Bar",
             tabPanel("Percent college",
                      sidebarLayout(
                        sidebarPanel(
                          selectInput(inputId = "state", label = "Select a state:",
                                      choices = unique(midwest$state),
                                      selected = "IL",
                                      multiple = TRUE),
                          hr(),
                          helpText("Data From Midwest data frame"),
                          textInput(inputId = "title", label = "Write a title!", value = "Midwest scatter plot comparison")
                        ),
                        mainPanel(
                          plotOutput("plot1")
                          #plotlyOutput(outputId = "scatterplot")
                        ),
                      ),
             ),
             tabPanel("Data Page",
                      sidebarLayout(
                        sidebarPanel(
                          sliderInput(
                            inputId = "area_choice",
                            label = "Range of Area",
                            min = 1, #area_range[1],
                            max = 10, #area_range[2],
                            value = 5 #area_range
                          )
                        ),
                        mainPanel(
                          plotOutput("plot2")
                        )
                      )
             )
  )
)

server <- function(input, output, session) {
    output$plot1 <- renderPlot(plot(cars))
    output$plot2 <- renderPlot(plot(pressure))
}

shinyApp(ui, server)

【讨论】:

  • 谢谢!你帮了很多忙!
猜你喜欢
  • 2014-03-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-10
  • 2014-04-21
  • 2015-09-27
  • 2018-07-26
  • 1970-01-01
相关资源
最近更新 更多