There's no return in this case because the way hist() works is by writing to R's current graphics context-which you can think of as the graphical equivalent of printing text to the console. square brackets, parentheses, braces - Square brackets were formerly called crotchets, round brackets are commonly called parentheses, and curly brackets are. This is because the code block is made up of three distinct expressions (assigning to x, assigning to bins, and calling hist), and whenever you have a function argument that's more than just a single expression, you need to use curly braces (you'll get a parse error if you omit the curly braces and try to run this code). In this second example, the curly braces are actually required for the renderPlot code block. When you assign to sub-variables of the output, there's no immediate value returned, but this is you telling Shiny to remember the recipe for populating that particular output (in this case, the one named distPlot). These input and output objects are implemented by Shiny. This is just boilerplate, but if you really want to know what's happening, this is just you telling Shiny what to do when a new session is created (i.e. The curly braces are not actually required, you could do renderTable( d() ) if you wanted to, but the braces make it feel more like a function.įor the second example, you're passing an anonymous function with parameters input and output into shinyServer. My first question is: why are there curly brackets inside the parentheses in this line of code? output$table <- renderTable( code not just once, but many times as the value of d() changes. The Shiny code isn't like the R code I'm used to reading and writing. I can produce simple apps, but I have a difficult time extending past the examples.
0 Comments
Leave a Reply. |