Reputation: 556
This seems like it should be easy, but I'd like to include a variable created in server.R in a sentence in UI.R.
For example, server.r:
averageSampleSize <- reactive({
round(mean(sampleSizes()), 2)
})
In server.R I'd access this as averageSampleSize()
I want to display this in the UI within a sentence, e.g., "Given the settings, across simulations the average sample size required is XXX"
I tried stuff like including in Server.r:
output$averageSampleSize <- renderText({averageSampleSize()})
And in ui.R:
HTML("Given blah blah ...", textOutput("averageSampleSize")
No luck. The last approach gives me cruft about how the variable is stored (list, etc.)
This seems really simple, but I can't figure it out.
Upvotes: 0
Views: 79
Reputation: 121618
For example:
library(shiny)
sampleSizes <- reactive(runif(100))
runApp(list(ui=bootstrapPage(
textOutput("averageSampleSize")),
server=function(input,output){
averageSize <- reactive({
round(mean(sampleSizes()), 2)
})
output$averageSampleSize <- renderText({paste('res=',averageSize())})
}))
Upvotes: 1