小编Mil*_*ily的帖子

隐藏/显示输出Shiny R.

我试图找出如何在每次用户更改widjets中的内容时显示和隐藏输出,如图形和表格.例如,我有一个名为"gender"的变量的滑块输入,有2个选项:男性和女性.我还有一个按钮,当用户点击它时执行估算.每当用户在不同的widjets之间更改至少一个选项时,我想隐藏输出.例如,在一次估计之后,用户决定仅更改教育级别,并且当用户单击sliderInput框时,我想隐藏先前的结果.

我试图使用R包的shinyjs和函数hide/show但它们不适用于输出.

如果不使用shinyjs包,你知道怎么做吗?

这是我的代码的一部分:

shinyUI(fluidPage(

  sidebarLayout(
    fluidRow( 
      column(4, wellPanel(

  fluidRow(
      column(5,selectInput("gender",
                          label = div("Sexe",style = "color:royalblue"),
                          choices = list("Male", "Female"),
                          selected = "Female")),

        # other different widjets..        

              column(8, plotOutput('simulationChange')),
              column(4, tableOutput('simulationChangeTable'),
                                    tags$style("#simulationChangeTable table {font-size:9pt;background-color: #E5E4E2;font-weight:bold;margin-top: 121px; margin-left:-30px;overflow:hidden; white-space:nowrap;text-align:left;align:left;}", 
                                    media="screen", 
                                    type="text/css"), 
                  fluidRow(
                     column(6, tableOutput('simulationChangeEsperance'),
                                    tags$style("#simulationChangeEsperance table {font-size:9pt;background-color: #E5E4E2;font-weight:bold;margin-top: -10px; margin-left:-30px;overflow:hidden; white-space:wrap;word-break: break-word;width:173px;text-align:left;}"))
                  )
              )
            )
        )
     )
    ))  

shinyServer(function(input, output, session) {
# part of my server.R code
    observe({


   if (input$gender|input$age|input$birthplace|input$education){  
      shinyjs::hide("simulationChange")
      shinyjs::hide("simulationChangeTable")
      shinyjs::hide("simulationChangeEsperance")
      }      
})
Run Code Online (Sandbox Code Playgroud)

谢谢.

r show-hide shiny

4
推荐指数
2
解决办法
1万
查看次数

更改 withProgress() 生成的消息框的样式和位置

withProgress()函数可以生成一个消息框,指示闪亮的应用程序正在运行。但该消息位于浏览器的右上角,文字尺寸较小,这使得该消息不那么引人注目。

所以我想知道有没有什么方法可以改变这个框的样式和位置,这样信息就更具有表现力。

这是我的代码的一部分:

output$plot <- renderPlot({ 
 if (input$button){

 withProgress(
              distributionPolygon(data(),unit="years",colors=c("black","gray30","gray50","gray70","blue3","dodgerblue3","steelblue1","lightskyblue1","red4","indianred3","orange","seagreen4"),main=title(),tpsMax=input$months),
              message = 'Loading...',
              detail = ''
              )
      }
   })
Run Code Online (Sandbox Code Playgroud)

message r shiny

3
推荐指数
1
解决办法
8343
查看次数

标签 统计

r ×2

shiny ×2

message ×1

show-hide ×1