【问题标题】:Argument "mainPanel" is missing with no default in R shiny缺少参数“mainPanel”,R 闪亮中没有默认值
【发布时间】:2021-03-10 02:58:46
【问题描述】:

我对 Shiny R 还很陌生!我想我可能缺少括号,但我一直在检查,但找不到错误。抱歉发布这么多代码!但是,如果你们可以检查我可能缺少括号的位置,是否有可能?

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


             
            

【问题讨论】:

  • 您的最后一个mainPanelsidebarPanel 内。

标签: r shiny shinyapps


【解决方案1】:
  1. 正如 Stephane 所说,您的 mainPanel 放错了位置
  2. 您有几个逗号没有进一步输入,这在 R 中可能会出现问题

还请注意,我必须添加 area_rangelibrary 调用。您的示例无法直接重现

library(shiny)
library(plotly)
area_range <- c(1,2)

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

shinyApp(ui, function(input, output) {})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-15
    • 2016-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-26
    • 2021-09-17
    相关资源
    最近更新 更多