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)
})
})
嘗試在您的'conditonalPanel'的conditons一個'.'('input.tabvals'而不是'$輸入tabvals')代替'$''見第Details' [這裏](HTTP:// shiny.rstudio.com/reference/shiny/latest/conditionalPanel.html) – NicE
謝謝!我剛剛嘗試過... –