每个选项卡的不同闪亮输入 - R

Different Shiny inputs for each Tab - R

我有一个闪亮的应用程序,它有多个用于查看股票数据的选项卡,我希望每个选项卡都有不同的输入选项。目前,inputs/filters 在没有功能的选项卡上占据了 space。例如,我的日期范围输入、滑块输入和复选框输入并不是查看我的股票股息选项卡所必需的。有什么方法可以控制每个选项卡的输入内容吗?这是我的代码的一般片段。

ui <- fluidPage(
  titlePanel("My App"),

  dateRangeInput("daterange", "Select a Time Frame to be Plotted", start = "2007-01-01", end = 
 Sys.Date()),

mainPanel(
 selectInput("stock", "Select a Stock(s):", choices = unique(df$Stock), multiple = TRUE, selected = "AAPL")),

sliderInput(),

checkboxGroupInput(),

tabsetPanel(
tabPanel("Stock Chart", plotlyOutput("line")),
tabPanel("Returns", reactableOutput('returns')),
tabPanel("Buy/Sell", plotlyOutput("buy_sell")),
tabPanel("Dividends", plotlyOutput("dividend")),
tabPanel("Trendline", reactableOutput("trendline")),
tabPanel("Ticker Lookup", DT::dataTableOutput("ticker"))

  )
)


server <- function(input, output, session) {


My ggplot graphs/table code here:

您只需将您的输入包含在它们各自的 tabPanel 中,例如您可以像这样在股票图表选项卡中插入日期范围输入。

ui <- fluidPage(
  titlePanel("My App"),

  dateRangeInput("daterange", "Select a Time Frame to be Plotted", start = "2007-01-01", end = 
 Sys.Date()),

mainPanel(
 selectInput("stock", "Select a Stock(s):", choices = unique(df$Stock), multiple = TRUE, selected = "AAPL")),

sliderInput(),

checkboxGroupInput(),

tabsetPanel(
tabPanel("Stock Chart", dateRangeInput("daterange1", "Select a Time Frame to be Plotted", start = "2007-01-01", end = Sys.Date()), plotlyOutput("line")),
tabPanel("Returns", reactableOutput('returns')),
tabPanel("Buy/Sell", plotlyOutput("buy_sell")),
tabPanel("Dividends", plotlyOutput("dividend")),
tabPanel("Trendline", reactableOutput("trendline")),
tabPanel("Ticker Lookup", DT::dataTableOutput("ticker"))

  )
)


server <- function(input, output, session) {


My ggplot graphs/table code here: