如何让侧边栏面板动态闪亮?

时间:2017-11-07 10:46:22

标签: r shiny

**#Ui.code:**

library(shiny)
fluidPage(
  titlePanel(title=h2(" Lucas Tvs",align="center")),
  sidebarPanel(



   conditionalPanel(condition="input.tabs1=='Profit Loss'",
selectInput("Operations","Select the desired Profit Loss statement",choices = profitloss1$Operations)),

br(),

   conditionalPanel(condition="input.tabs1=='Profit Loss'",
          selectInput("summary1","Select the desired Summary",choices = summary1$OPERATIONS)), 

 conditionalPanel(condition="input.tabs1=='Ratio'",
      selectInput("Ratio","Select the desired Ratios",choices=ratios1$Ratios)),
 br(),
 conditionalPanel(condition="input.tabs1=='Ratio'",
                  selectInput("summary","Select the desired Summary",choices = summary$RATIO)),


 conditionalPanel(condition="input.tabs1=='Balancesheet'",
    selectInput("Particulars","Select the desired Balancesheet statement", choices = Balancesheet$Particulars)),

 br(),

    conditionalPanel(condition="input.tabs1=='Balancesheet'",
      selectInput("summary2","Select the desired Summary",choices = summary2$PARTICULARS))

 ),


    mainPanel(

    tabsetPanel(id="tabs1", 

   tabPanel("Profit Loss",column(5,tableOutput("profitloss")), column(7,plotOutput("plot")),tableOutput("summary1")),
   tabPanel("Ratio",column(5,tableOutput("Ratio")),column(7,plotOutput("plot2")),tableOutput("summary")),
   tabPanel("Balancesheet",column(5,tableOutput("Balancesheet")),column(6,plotOutput("plot1")),tableOutput("summary2"))

    )      


)
)

在UI部分,我在主面板中创建了3个选项卡,在侧边栏面板中创建了2个选项。所有这些都是动态响应但现在我希望我的代码向我显示侧栏面板中的选择输入都是相互依赖。      #server代码:

library(shiny)
library(ggplot2)
shinyServer(function(input,output){

    output$profitloss<-renderTable({
      oporationfilter<-profitloss1[profitloss1$Operations==input$Operations,c("Years","Value")]

    })
    output$Ratio<-renderTable({
      ratiofilter<-ratios1[ratios1$Ratios==input$Ratio,c("Years","Value")]
    })

    output$Balancesheet<-renderTable({
      Balancesheetfilter<-Balancesheet[Balancesheet$Particulars==input$Particulars,c("Years","Value")]
    })

   output$summary<-renderTable({
     summaryfilter<-summary[summary$RATIO==input$summary,c("Mean","Standard.Deviation","CAGR.1","CAGR.3","CAGR.5")]
   })
   output$summary1<-renderTable({
     summary1filter<-summary1[summary1$OPERATIONS==input$summary1,c("Mean","Standard.Deviation","CAGR.1","CAGR.3","CAGR.5","CAGR.7")]
   })

   output$summary2<-renderTable({
  summary2filter<-summary2[summary2$PARTICULARS==input$summary2,c("Mean","Standard.Deviation","CAGR.1","CAGR.3","CAGR.5")]
   })



    output$plot<-renderPlot({
      options(scipen = 999)
      p<-ggplot(data = profitloss1[profitloss1$Operations==input$Operations,]
                ,aes(x=Years,y=Value))
      p+geom_line()+xlab("Years")+ylab("Value in Lakhs")+ggtitle("Profitloss Plot")
     })


    output$plot2<-renderPlot({
      q<-ggplot(data = ratios1[ratios1$Ratios==input$Ratio,]
                ,aes(x=Years,y=Value))
      q+geom_line()+xlab("Years")+ylab("value in lakhs")+ggtitle("Ratios Plot ")
    })

    output$plot1<-renderPlot({
      q<-ggplot(data = Balancesheet[Balancesheet$Particulars==input$Particulars,]
                ,aes(x=Years,y=Value))
      q+geom_line()+xlab("Years")+ylab("value in lakhs")+ggtitle("Balancesheet Plot")
    })
  })

这是现在设计网站的代码我希望我的两个选择输入应该是相互依赖的。 例如:如果在下拉菜单中选择XXX,​​我应该在第二个选择输入中自动获得相同的输出。

0 个答案:

没有答案