闪亮的多输入不显示

时间:2018-03-10 13:47:52

标签: r shiny

我想在UI中输入多个输入,但是当我运行应用程序时只显示第一个输入。我看到其他闪亮的代码使用多个输入似乎工作正常,我完全失去了为什么我的selectInput(“input2”)没有显示。任何帮助将不胜感激!

library(shiny)
library(ggplot2)

data1 <- read.csv("CollegeScorecardMarch.csv", stringsAsFactors = FALSE)
# Two input variables
ui <- fluidPage(
  titlePanel("2 Variable Plot"),
  sidebarLayout(
    sidebarPanel(
  selectInput("input1", "Variable 1",
          choices = c("npt4_pub", "md_earn_wne_p6"),
  selectInput("input2", "Variable 2",
          choices = c("npt4_pub", "md_earn_wne_p6"))
  )
  ),

      mainPanel(
         plotOutput("distPlot")
      )
   )
  )

1 个答案:

答案 0 :(得分:1)

你刚刚放错了。尝试缩进代码( Ctrl + I 在RStudio中)以避免此类错误

library(shiny)
library(ggplot2)

#data1 <- read.csv("CollegeScorecardMarch.csv", stringsAsFactors = FALSE)
# Two input variables
ui <- fluidPage(
  titlePanel("2 Variable Plot"),
  sidebarLayout(
    sidebarPanel(
      selectInput("input1", "Variable 1",
                  choices = c("npt4_pub", "md_earn_wne_p6")),
      selectInput("input2", "Variable 2",
                  choices = c("npt4_pub", "md_earn_wne_p6")
      )
    ),

    mainPanel(
      plotOutput("distPlot")
    )
  )
)

shinyApp(ui, function(...){})