我正在使用Shiny开发应用程序。我需要将字段放置在sidePanel旁边的conditionalPanel中,但是使用我现有的代码,它位于“ Go”按钮下方。仅当单击Go并选择selectInput时,才显示条件面板。有人可以帮忙吗?
我尝试使用column(3,*),wellpanel无效。
library(shiny)
ui <- fluidPage(
titlePanel("Nomenclature Calculator"),
fluidRow(
column(3, wellPanel(
textInput("account","Enter the Account Name",""),
tags$hr(),
textInput("advertiser","Enter the Advertiser Name",""),
tags$hr(),
textInput("insertionorderid","Enter the Insertion Order ID",""),
tags$hr(),
textInput("campaignname","Enter the Campaign Name",""),
tags$hr(),
selectInput("dropdown", "Choose from the drop down",
list("flight","tactic","AD-Video","AD-NonVideo","Pixel"),selected = FALSE ,multiple = FALSE,selectize = FALSE, size=4),
tags$hr(),
actionButton("goButton", "Go")
)),
conditionalPanel(
condition = "input.dropdown == 'flight'",
textInput("flightname","Enter the flight Name",""),
selectInput("addedvalue", "Added Value:",
c("No","Yes")),
tags$hr(),
actionButton("go", "Go")
#textInput("Tactic Name",paste0("Enter the",input$dropdown, "Name"))
),
))
仅在单击Go并选择selectInput时,才显示条件面板。并在侧面板旁边。
答案 0 :(得分:0)
尝试一下:
ui <- fluidPage(
titlePanel("Nomenclature Calculator"),
fluidRow(
column(3, wellPanel(
textInput("account","Enter the Account Name",""),
tags$hr(),
textInput("advertiser","Enter the Advertiser Name",""),
tags$hr(),
textInput("insertionorderid","Enter the Insertion Order ID",""),
tags$hr(),
textInput("campaignname","Enter the Campaign Name",""),
tags$hr(),
selectInput("dropdown", "Choose from the drop down",
list("flight","tactic","AD-Video","AD-NonVideo","Pixel"),
selected = FALSE ,
multiple = FALSE,
selectize = FALSE,
size=4),
tags$hr(),
actionButton("goButton", "Go")
)),
column(3, conditionalPanel(
condition = "input.dropdown == 'flight'",
textInput("flightname","Enter the flight Name",""),
selectInput("addedvalue", "Added Value:",
c("No","Yes")),
tags$hr(),
actionButton("go", "Go")
#textInput("Tactic Name",paste0("Enter the",input$dropdown, "Name")),
column(3,conditionalPanel(
condition = "input.dropdown == 'tactic'",
textInput("tacticname","Enter the tactic Name",""),
tags$hr(),
actionButton("go1", "Go")
#textInput("Tactic Name",paste0("Enter the",input$dropdown, "Name"))
)),
column(3,conditionalPanel(
condition = "input.dropdown == 'AD-NonVideo'",
textInput("channelname","Enter the Channel Name",""),
tags$hr(),
textInput("adname","Enter the AD Name",""),
tags$hr(),
numericInput("width","Enter the AD Width",""),
tags$hr(),
numericInput("height","Enter the AD Height",""),
tags$hr(),
actionButton("go2", "Go")
))
)
)
)
)
答案 1 :(得分:0)
由于条件面板是互斥的,因此可以将它们放在单个column
中。这样,您就不会有不希望的空格。
ui <- fluidPage(
titlePanel("Nomenclature Calculator"),
fluidRow(
column(3, wellPanel(
textInput("account","Enter the Account Name",""),
tags$hr(),
textInput("advertiser","Enter the Advertiser Name",""),
tags$hr(),
textInput("insertionorderid","Enter the Insertion Order ID",""),
tags$hr(),
textInput("campaignname","Enter the Campaign Name",""),
tags$hr(),
selectInput("dropdown", "Choose from the drop down",
list("flight","tactic","AD-Video","AD-NonVideo","Pixel"),
selected = FALSE ,
multiple = FALSE,
selectize = FALSE,
size=4),
tags$hr(),
actionButton("goButton", "Go")
)),
column(9,
conditionalPanel(
condition = "input.dropdown == 'flight'",
textInput("flightname","Enter the flight Name",""),
selectInput("addedvalue", "Added Value:",
c("No","Yes")),
tags$hr(),
actionButton("go", "Go")
),
#textInput("Tactic Name",paste0("Enter the",input$dropdown, "Name")),
conditionalPanel(
condition = "input.dropdown == 'tactic'",
textInput("tacticname","Enter the tactic Name",""),
tags$hr(),
actionButton("go1", "Go")
#textInput("Tactic Name",paste0("Enter the",input$dropdown, "Name"))
),
conditionalPanel(
condition = "input.dropdown == 'AD-NonVideo'",
textInput("channelname","Enter the Channel Name",""),
tags$hr(),
textInput("adname","Enter the AD Name",""),
tags$hr(),
numericInput("width","Enter the AD Width",""),
tags$hr(),
numericInput("height","Enter the AD Height",""),
tags$hr(),
actionButton("go2", "Go")
))
)
)
shinyApp(ui, function(input,output){})