2016-05-11 10 views
0

税計算アプリケーションを作成しようとしています。サイドバーでは、tabsetPanelを使用して、個人と税率に関連する入力が異なる2つのパネルを表示しています。Shiny/R:出力が表示されない

mainPanelは、グラフなどのプロットを行う予定のtabsetPanelも使用します。私は動作していないような更新ボタンがあります。

ui.R 

は次のようになります。

shinyUI(fluidPage(
titlePanel("flatTax"), 
sidebarLayout(
sidebarPanel(
    h1("Flat Tax Calculator"), 
    helpText("Input your information below and see how a flat tax could 
affect your tax bill."), 

    #Individual Specific Variables 
    tabsetPanel(
    tabPanel("You", 
    numericInput(inputId = "incomeNum", 
       label = "Your annual income:", 
       value = 0 
    ), 

    textInput(inputId = "testText", 
       label = "Test Input" 
      ), 
    ), 

    tabPanel("Tax Settings", 
    sliderInput(inputId = "basicIncome", 
       label = "Choose a monthly basic income", 
       value = 600, min = 0, max = 1200, step = 50 
    ), 

    sliderInput(inputId = "taxFree", 
       label = "Choose a tax free allowance", 
       value = 10000, min = 0, max = 20000, step = 250 
    ), 

    sliderInput(inputId = "flatIncomeTax", 
       label = "Choose a flat tax rate", 
       value = 50, min = 0, max = 100, step = 1 
    ), 

    sliderInput(inputId = "flatPropertyTax", 
       label = "Choose a land value tax rate", 
       value = 1, min = 0, max = 100, step = 1 
)), 

    # Action Button 
    actionButton(inputId = "updateButton", 
       label = "Update"), 
    plotOutput("text") 
) 
), 


mainPanel(
    tabsetPanel(
    tabPanel("Summary", 
     h3("Test Output", textOutput("test"), 
     h3("Your new income tax bill is:", textOutput("incomeFT")), 
     h3("Your new property tax bill is:", textOutput("propertyFT")), 
     textOutput("annualBasicIncome") 
     ) 
     ), 
    tabPanel("Graphs", 
      h3("Placeholder"), 
      h3("Holding the place"), 
      h3("Plaice holster") 
     ) 
    ) 
) 
) 
)) 


server.R 

は次のようになります。反応がなければ

shinyServer(
function(input, output) { 


#action button stuff 
incomeFT <- eventReactive(input$updateButton, { 
    ((input$incomeNum-input$taxFree)/100*input$flatIncomeTax) 
}) 

output$incomeFT <- renderPrint({ 
    incomeFT() 
}) 

propertyFT <- eventReactive(input$updateButton, { 
    input$propertyNum/100*input$flatPropertyTax 
}) 

output$propertyFT <- renderPrint({ 
    propertyFT() 
})  

annualBasicIncome <- eventReactive(input$updateButton, { 
    switch(as.numeric(input$relStat), 
     return((input$basicIncome*12)+((input$basicIncome*12)*input$childNum)), 
     return((2*(input$basicIncome*12))+((input$basicIncome*12)*input$childNum)) 
) 
    }) 

output$annualBasicIncome <- renderPrint({ 
    annualBasicIncome() 
}) 

test <- eventReactive(input$updateButton, { 
    input$testText 
}) 

output$test <- renderText({ 
    test() 
}) 
}) 

動作しているようですが、ボタンを使用することが少ない気が散ることができます。私はtextOutputの代わりにverbatimTextOutputを使用しようとしましたが、グレーのバーはメインパネルに出力されません。

助けてください。

答えて

0

何らかの理由でactionButtontabsetPanelの内部で機能しません。あなたがそれを外に(そしてsidebarPanelの中に)置くと、それはうまくいくでしょう。 tabPanelごとに1つずつactionButtonを使用することをお勧めします。私はそれを試していないが、それは動作するはずだと思う。試してみたら、結果を教えてください。

乾杯。

+0

もう一度!ありがとう。 – gizzard

関連する問題