我想在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")
)
)
)
答案 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(...){})