2015-05-19 98 views
1

相关的侧边栏我有一个闪亮的仪表盘具有使用tabBox三个标签,我想用激活的标签,以确定/使人们看到了相关的仪表盘侧边栏输入。目前它们全部同时出现......我希望一些消息会根据启动的标签消失。片闪亮的仪表盘

下面是我目前的尝试。

任何帮助,将不胜感激。

ui.R脚本如下:

#ui.R 
library(shiny) 
library(shinydashboard) 

header <- dashboardHeader(
    title = 'Simple dashbaord' 
) 
body <- dashboardBody(
    fluidRow(
    column(width=12, 
      tabBox(
      id='tabvals', 
       width=NULL, 
       tabPanel('TAB name1', 
         plotOutput('plot1'),value=1), 
       tabPanel('TAB name2', 
         plotOutput('plot2'),value=2), 
       tabPanel('TAB name3', 
         plotOutput('plot3'),value=3) 
      ) 
    ) 
    ) 
) 


dashboardPage(
    header, 
    dashboardSidebar(
    conditionalPanel(
     condition = "input$tabvals == 1", 
     sliderInput('slider1','Slider for tab1:',min=1,max=3000,value=30), 
     sliderInput('slider2','2nd Slider for tab1:',min=1,max=3000,value=300) 
    ), 
    conditionalPanel(
     condition = "input$tabvals == 2", 
     sliderInput('slider3','Slider for tab2:',min=1,max=1000,value=10), 
     sliderInput('slider4','2nd Slider for tab2:',min=1,max=1000,value=500) 
    ), 
    conditionalPanel(
     condition = "input$tabvals == 3", 
     sliderInput('slider5','Slider for tab3:',min=1,max=3000,value=30), 
     sliderInput('slider6','2nd Slider for tab3:',min=1,max=3000,value=30) 
    ) 
    ), 
    body 
) 

server.R脚本如下:

require(shiny) 
require(ggplot2) 

shinyServer(function(input,output){ 

    output$plot1 <- renderPlot({ 

    out <- ggplot(data.frame(X1=rnorm(input$slider1,input$slider2)),aes(X1))+ 
     geom_density(fill='light blue')+ 
     theme_minimal()+ 
     xlab('X value')+ 
     ylab('')+ 
     ggtitle('Distribution of X')+ 
     theme(
     axis.text.y = element_blank(), 
     axis.ticks = element_blank()) 

    print(out) 
    }) 
    output$plot2 <- renderPlot({ 
    out <- ggplot(data.frame(X1=rnorm(input$slider3,input$slider4)),aes(X1))+ 
     geom_density(fill='light blue')+ 
     theme_minimal()+ 
     xlab('X value')+ 
     ylab('')+ 
     ggtitle('Distribution of X')+ 
     theme(
     axis.text.y = element_blank(), 
     axis.ticks = element_blank()) 

    print(out) 
    }) 
    output$plot3 <- renderPlot({ 
    out <- ggplot(data.frame(X1=rnorm(input$slider5,input$slider6)),aes(X1))+ 
     geom_density(fill='light blue')+ 
     theme_minimal()+ 
     xlab('X value')+ 
     ylab('')+ 
     ggtitle('Distribution of X')+ 
     theme(
     axis.text.y = element_blank(), 
     axis.ticks = element_blank()) 

    print(out) 
    }) 


}) 
+4

尝试在您的'conditonalPanel'的conditons一个'.'('input.tabvals'而不是'$输入tabvals')代替'$''见第Details' [这里](HTTP:// shiny.rstudio.com/reference/shiny/latest/conditionalPanel.html) – NicE

+0

谢谢!我刚刚尝试过... –

回答

3

从更改条件:

condition = "input$tabvals == 1", 

到:

condition = "input.tabvals == 1", 

帮助。这应该在Shiny中更加一致吗?