简体   繁体   English

闪亮/ R:不显示输出

[英]Shiny/R: Outputs not displaying

so I'm trying to make a tax calculation app. 所以我正在尝试制作一个税收计算应用程序。 In the sidebar I'm using tabsetPanel to display two panels with different inputs relating to the individual and then tax rates. 在边栏中,我使用tabsetPanel来显示两个面板,这些面板的输入与个人有关,然后与税率有关。

The mainPanel will also be using tabsetPanel where I plan to plot graphs etc. I have an update button that doesn't seem to be working. mainPanel还将使用tabsetPanel,我打算在其中绘制图形等。我有一个更新按钮,该按钮似乎不起作用。

ui.R

Looks like this: 看起来像这样:

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

Looks like this: 看起来像这样:

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()
})
})

Without reactivity it seems to work, but the button makes it less distracting to use. 没有反应性,它似乎可以工作,但是按钮使它的使用分散了注意力。 I've tried using verbatimTextOutput instead of textOutput but grey bars are sent across the main panel with not outputs in. 我试过使用verbatimTextOutput而不是textOutput,但是灰色条在整个面板上发送而没有输出。

Help please? 请帮助?

For some reason, the actionButton does not work inside the tabsetPanel . 由于某些原因, actionButtontabsetPanel内部tabsetPanel If you put it outside it (and inside sidebarPanel ) it will work. 如果将它放在它的外面(和sidebarPanel里面),它将起作用。 I suggest you try to use one actionButton for each tabPanel . 我建议您尝试为每个tabPanel使用一个actionButton I haven't try it, but I believe it should work. 我还没有尝试过,但是我相信它应该可以工作。 Please, if you try it, let me know the results. 请尝试一下,让我知道结果。

Cheers. 干杯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM