Reputation: 344
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)
}
)
}
This is my server.r code.I have created an action button with input id "click" to generate barplot but the graph is generated directly once I upload the file without clicking on action button.What changes should I make in the code? I tried using eventReactive but result remained the same
Upvotes: 2
Views: 121
Reputation: 17369
You should use
shiny server <- function (input, output)
{
plot <- eventReactive (input $click,
{
[code to develop plot]
}
)
output$bar_plot <- renderPlot ({ plot () })
}
Upvotes: 1