我想有多个标签,每个标签都有自己的侧边栏,我需要 selectInput
在第一个选项卡中,和 sliderInput
在第二个选项卡中。
任何人都可以帮忙吗?
我的代码:
ui <- fluidPage(
headerPanel("Terrorism in The World"),
sidebarPanel(
selectInput("Country", "Select Country", choices = sort(unique(mydat$Country)), selected = "Iraq")
,sliderInput("year", "Year:", min = 1968, max = 2009, value = 2009, sep='')
),
mainPanel(
tabsetPanel(
tabPanel("Map",htmlOutput("Attacks")),
tabPanel("plot",
fluidRow(
column(8, plotlyOutput("trendheatrPlot", height = "300px",width = 700)),
column(7, plotlyOutput("trendstakbarPlot", height = "300px",width = 700))
)
)
)
)
)
最佳答案
我制作了一个简单的 UI 模板,您可以根据您的描述使用。我还将您的列规范从 8,7 更改为 7,5,因为 Shiny 的 UI 基于 12 网格系统。这是代码:
library(shiny)
library(plotly)
shinyApp(
ui = fluidPage(
tabsetPanel(
tabPanel("Map", fluid = TRUE,
sidebarLayout(
sidebarPanel(selectInput("Country", "Select Country", choices = "", selected = "")),
mainPanel(
htmlOutput("Attacks")
)
)
),
tabPanel("plot", fluid = TRUE,
sidebarLayout(
sidebarPanel(sliderInput("year", "Year:", min = 1968, max = 2009, value = 2009, sep='')),
mainPanel(fluidRow(
column(7, plotlyOutput("")),
column(5, plotlyOutput(""))
)
)
)
)
)
),
server = function(input, output) {
}
)
关于r - Shiny 的多个标签和每个标签中的不同侧边栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44222796/