2017-05-28 77 views
3

我想有多個標籤,有自己的側邊欄每個選項卡,我需要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)) 
       ) 
      ) 
     ) 
    ) 
) 

回答

6

我讓你可以使用根據您的描述一個簡單的UI模板。我還將列規範從8,7更改爲7,5,因爲閃亮的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) { 

    } 
) 
+0

非常感謝你dvarelas,我會運行它,讓你知道。 –

+0

它像一個魅力工作,謝謝。有沒有辦法將邊欄移動到頁面的頂部中間? –

+1

@Sazan Abdalrhmam不客氣。你能接受答案,以便其他人知道它的工作。你也可以張貼你在想什麼的圖片,因爲我無法想象中間的側邊欄。 – dvarelas