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的操作按钮&#34;点击&#34;生成条形图但是我上传文件后直接生成图表而不点击操作按钮。我应该在代码中做出哪些更改?我尝试使用eventReactive,但结果保持不变
答案 0 :(得分:1)
你应该使用
shiny server <- function (input, output)
{
plot <- eventReactive (input $click,
{
[code to develop plot]
}
)
output$bar_plot <- renderPlot ({ plot () })
}