【问题标题】:Shiny server and shiny apps闪亮的服务器和闪亮的应用程序
【发布时间】:2016-05-23 05:21:40
【问题描述】:
server <- function (input , output  )
{
    output$bar_plot <- renderPlot( 
        {   
            input$click
            inFile <- input$file1
            if (is.null(inFile))
               return(NULL)
            mydata <- read.csv(inFile$datapath)
            resources <-  factor (mydata$Resource.Name)
            stan <-  tapply (mydata$Standard.Hours,resources, sum , na.rm=TRUE)
            bil <-  tapply (mydata$Billable.Hours,resources, sum , na.rm=TRUE)
            bu <- bil*100 / stan
            mp <- barplot (bu,col=colors(27),las=2,yaxt="n",ylim=c(0,200),main="Billable      Utilization India-DSI")
            bu<- round(bu,2)
            text(mp, bu,labels=bu, pos = 3)
        }
    )
}

这是我的 server.r 代码。我创建了一个输入 id 为“click”的操作按钮来生成条形图,但是一旦我上传文件而不点击操作按钮,就会直接生成图表。我应该在代码?我尝试使用 eventReactive 但结果保持不变

【问题讨论】:

    标签: r shiny shiny-server


    【解决方案1】:

    你应该使用

    shiny server <- function (input, output)
    {
      plot <- eventReactive (input $click,
        {
           [code to develop plot]
        }
      )
    
    output$bar_plot <- renderPlot ({ plot () })
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-01
      • 2014-08-09
      • 1970-01-01
      • 2016-12-28
      • 2022-10-05
      • 1970-01-01
      • 2020-01-26
      • 2018-09-03
      相关资源
      最近更新 更多