R Shiny App错误 - 无法找到任何UI

时间:2018-04-26 16:57:35

标签: r shiny

我写了这段代码,最初Shiny工作得很好,应用程序启动了:

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

但是当我添加任何UI元素时,例如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")
)

我收到错误:

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

知道可能导致这种情况的原因吗?我尝试了其他选项而不是单选按钮并收到了同样的错误。我的服务器文件只是一个带有服务器功能的空文件。

1 个答案:

答案 0 :(得分:0)

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