Reputation: 1036
I am building a shiny application, and I would like there to be a field like this that displays the probability someone will return (given a bunch of underlying models):
And it pretty much works, except its in decimal form:
The code pasting into that box looks like this:
paste(a$result)
I can get it to look "correct" and say '83%' for instance, instead of 0.83000.....
by using this code:
paste( c( round(a$result, digits=2))*100,"%")
But the problem is.... while this code does work, until you hit the "calculate" button, it looks like this:
I wish I could provide some sample data to try but given the interactiveness of the shiny app, that'd be very hard. Is there a simple solution?
Upvotes: 0
Views: 37
Reputation: 206187
Use the function shiny::req
to make sure required values are present before performing the calculation. For example
paste(c( round(req(a$result), digits=2))*100,"%")
Upvotes: 3