Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mainPanel argument missing in ui.r file using R's Shiny package

Tags:

r

shiny

I am running Shiny in R to create a GUI, and I receive the following error: ERROR: argument "mainPanel" is missing, with no default

However, as you can see from my code below in the ui.r file, I do have mainPanel included at the bottom, which should be getting successfully passed to 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")
    )



)
)

I have also made sure to include a comma before mainPanel, as suggested in Error in RShiny ui.r argument missing

Any suggestions are greatly appreciated.

like image 494
warship Avatar asked Aug 10 '14 05:08

warship


1 Answers

The mainPanel needs to be called inside the sidebarLayout function. See ?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")
    )
  )
)
)
like image 125
jdharrison Avatar answered Sep 17 '22 00:09

jdharrison