代码之家  ›  专栏  ›  技术社区  ›  Akash Verma

闪亮的服务器和闪亮的应用程序

  •  2
  • Akash Verma  · 技术社区  · 9 年前
    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)
            }
        )
    }
    

    这是我的服务器。r代码。我已经创建了一个输入id为“click”的动作按钮来生成条形图,但是当我上传文件而不单击动作按钮时,会直接生成图形。我应该对代码进行哪些更改?我尝试使用eventReactive,但结果保持不变

    1 回复  |  直到 9 年前
        1
  •  1
  •   Benjamin    9 年前

    你应该使用

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