使用R的Shiny包在ui.r文件中缺少mainPanel参数

war*_*hip 8 r shiny

Shiny在R中运行以创建GUI,我收到以下错误:ERROR: argument "mainPanel" is missing, with no default

但是,正如您在ui.r文件中的代码中所看到的,我确实已经mainPanel包含在底部,应该成功传递给sidebarLayout:

require(shiny)

shinyUI(fluidPage(
titlePanel("Approach"),
sidebarLayout(
    sidebarPanel(
        fileInput('file1', 'Choose file to upload',
                accept = c(
                    'text/csv',
                    'text/comma-separated-values',
                    'text/tab-separated-values',
                    'text/plain',
                    '.csv',
                    '.tsv'
                )
        )

    )
),
    mainPanel(
        plotOutput("plot")
    )



)
)
Run Code Online (Sandbox Code Playgroud)

我之前也确保包含一个逗号mainPanel,正如RShiny ui.r中的Error错误中所建议的那样

任何建议都非常感谢.

jdh*_*son 12

mainPanel需要的内部调用sidebarLayout函数.见?sidebarLayout:

require(shiny)

shinyUI(fluidPage(
  titlePanel("Approach"),
  sidebarLayout(
    sidebarPanel(
      fileInput('file1', 'Choose file to upload',
                accept = c(
                  'text/csv',
                  'text/comma-separated-values',
                  'text/tab-separated-values',
                  'text/plain',
                  '.csv',
                  '.tsv'
                )
      )

    ),
    mainPanel(
      plotOutput("plot")
    )
  )
)
)
Run Code Online (Sandbox Code Playgroud)