- Web Application Development with R Using Shiny(Third Edition)
- Chris Beeley Shitalkumar R. Sukhdeve
- 260字
- 2021-07-16 17:52:11
An optional exercise
If you want to have a practice before we move on, take the existing code and modify it so that the output is a plot of a user-defined number of observations, with the text as the title of the plot. The plot call should look like the following:
hist(rnorm(XXXX), main = "YYYY")
In the preceding line of code, XXXX is a number taken from a function in ui.R that you will add (sliderInput() or numericInput()) and YYYY is the text output we already used in the minimal example. You will also need to make use of renderPlot(); type ?renderPlot in the console for more details.
So far in this chapter, we have looked at a minimal example and learned about the basic commands that go in the server.R and ui.R files. Thinking about what we've done in terms of reactivity, the ui.R file defines a reactive value, input$comment. The server.R file defines a reactive expression, renderText(). It depends on input$comment.
Note that this dependence is defined automatically by Shiny. The renderText() expression uses an output from input$comment, so Shiny automatically connects them. Whenever input$comment changes, renderText() will automatically run with the new value. The optional exercise gave two reactive values to the renderPlot() call, and so, whenever either changes, renderPlot() will be rerun. In the rest of this chapter, we will look at an application that uses some slightly more advanced reactivity concepts, and by the end of the book, we will have covered all the capabilities that Shiny offers and when to use them.
- 物聯網與北斗應用
- Building E-commerce Sites with VirtueMart Cookbook
- Web Application Development with R Using Shiny
- 正在爆發的互聯網革命
- 大話社交網絡
- React:Cross-Platform Application Development with React Native
- Wireshark網絡分析就這么簡單
- 物聯網技術與應用
- 物聯網之霧:基于霧計算的智能硬件快速反應與安全控制
- Master Apache JMeter:From Load Testing to DevOps
- 互聯網+思維與創新:通往未來的+號
- Practical Web Penetration Testing
- Dart Cookbook
- 數字王國里的虛擬人:技術、商業與法律解讀
- Enterprise ApplicationDevelopment with Ext JSand Spring