Shiny Happy…Animation!!!

I looked at the website for the animation option in Module 12. I then installed the animation package and simply copied and pasted code for his demonstration of the law of large numbers. The Law of Large Numbers is about the average of a sample and that this average will tend towards the expected value as the sample size increases. I had always thought it was more that the average tended towards a central value as the sample size increased but perhaps my conception of central value is what he means by expected value. In this instance the author states his animated plot is done by using the Chi-Squared distribution as the population distribution. I then made a screencast of running the code in RStudio but discovered that WordPress won’t let me upload a weblink to the Jing screencast, so I used Camtasia (I bought it last year because I was having trouble doing what I wanted with iMovie) to do a recording and uploaded the to Youtube:

I would like to play with the code to change the color but am not sure where to start yet and I want to look at Shiny to see what that is all about. I am also tempted to try to download ImageMagik but I have been downloading software all over the place and am afraid to add to the mess. So back to the drawing board!

To learn more about Shiny there is an extensive tutorial at: I basically copied and pasted code in Part 1 of the tutorial and using this code from it:

                            label = “Choose a number”,
                            value = 25, min = 1, max = 100),
# rule 1: save objects to display to output$
# Example: server
# output$hist
# rule 2: Build objects to display with render*()
# Example: renderPlot({ hist(rnorm(100)) })
# rule 3: Access input values with input$
# Example: server
# output$hist
shinyApp(ui = ui, server = server)

I was able to do this and demonstrate the results in this YouTube video:

but I got a little lost when it came to sharing the app.

I decided to follow the assignment and went to the gallery to look at the much more colorful and interesting examples. I particularly liked this one: as it is an example of rising health care costs in the United States without an equivalent increase in life expectancy. In areas without a substantial increase in per capita health care spending life expectancy is increasing and in some cases surpassing the US. If this were used with other information and discussion it demonstrates the insanity of our health care system. If you take a look it demonstrates a very weak link between per capita health care spending and life expectancy, where the US spending is increasing, life expectancy is essentially remaining the same. Except for a couple of countries that have higher spending and also have higher life expectancy, most other countries have increased life expectancy (although a small increase in many cases) without the astronomical rise in spending as we have in the US. I did a video of it too:

The gallery includes code and it will be interesting to try to change the data set and see what I can come up with but I think I will stop here for now! I am hoping for my final project to do something with Shiny or animation and perhaps I will even download ImageMagik to demonstrate it rather than do a screen recording.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s