I've gone through some Shiny tutorials. I can produce simple apps, but I have a difficult time extending past the examples. The Shiny code isn't like the R code I'm used to reading and writing.
My first question is: why are there curly brackets inside the parentheses in this line of code?
output$table <- renderTable({
d()
})
I see that renderTable
wants an expression
object as its input argument. What is the relationship between the curly brackets and expressions? Is the input argument to renderTable
coerced to an expression? To be honest, I've never encountered expression objects before.
In this second example, why is the variable output
listed as an input argument to function
? Why is there no return
argument? Why again are there curly brackets inside the call to renderPlot
?
Many thanks! And apologies for the very general questions.
shinyServer(function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
})