Digvijay Sawant
Digvijay Sawant

Reputation: 1079

R Shiny App Error - Couldn't Find Any UI

I wrote this code and initially Shiny worked just fine and the app started:

library(shiny)    
ui <- fluidPage(
  titlePanel("Title"),
  sidebarPanel(
    sliderInput("priceInput", "Price", min = 0, max = 100,
                value = c(25,40), pre = "$")
  ),
  mainPanel("Results")
)

But when I add any UI element to it, for example radioButton:

ui <- fluidPage(
  titlePanel("Title"),
  sidebarPanel(
    sliderInput("priceInput", "Price", min = 0, max = 100,
                value = c(25,40), pre = "$"),
    radioButtons("typeInput", "Product type",
                 choices = c("p1", "p2", "p3"),
                 selected = "p1")
  ),
  mainPanel("Results")
)

I get an error:

Shiny couldn't find any UI for this application. We looked in:    
www/index.html
ui.R
app.R

Any idea what might cause this? I tried other options instead of a radio button and received the same error. My server file is just an empty file with the server function.

Upvotes: 1

Views: 3007

Answers (1)

Teodor Ciuraru
Teodor Ciuraru

Reputation: 3477

Add the elements inside a sidebarLayout(...)

ui <- fluidPage(
  titlePanel("title panel"),

  sidebarLayout(
    sidebarPanel(
         sliderInput("priceInput", "Price", min = 0, max = 100,
            value = c(25,40), pre = "$"),
         radioButtons("typeInput", "Product type",
             choices = c("p1", "p2", "p3"),
             selected = "p1")),ț
    )
    mainPanel("main panel")
  )
)

Upvotes: 1

Related Questions