因为我编写了控制单个数据表的代码,代码是
在ui下:library(shiny)
fluidPage(
titlePanel(title=h2(" Lucas Tvs",align="center")),
sidebarPanel(
conditionalPanel(condition="input.tabs1=='profitloss'",
selectInput("Operations","Select the desired ProfitLoss statement",choices = profitloss1$Operations)),
conditionalPanel(condition="input.tabs1=='Ratio'",
selectInput("Ratio","Select the desired Ratios",choices=ratios1$Ratios)),
conditionalPanel(condition="input.tabs1=='Balancesheet'",
selectInput("Particulars","Select the desired Balancesheet statement", choices = Balancesheet$Particulars))
),
mainPanel(
tabsetPanel(id="tabs1",
tabPanel("profitloss",column(5,tableOutput("profitloss")), column(7,plotOutput("plot"))),
tabPanel("Ratio",column(5,tableOutput("Ratio")),column(6,plotOutput("plot2"))),
tabPanel("Balancesheet",column(5,tableOutput("Balancesheet")),column(6,plotOutput("plot1")))
)
)
)
在服务器下:
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$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("Balance sheet Plot")
})
})
现在我想在主面板中添加一个表,但控制将来自单个输入。 它的意思是如果我点击profitloss1或比率的操作....那么这将显示两个表,只需点击一下。