I came up with a weekly R challenge as a way to “force” myself into learning new things. One figure, every week! The catch is that every time I should be trying something new… maybe I’ll use a new type of visualization, or maybe I’ll explore a new dataset. Initially I thought it would be neat if there was some unifying topic, e.g. water, but, then I decided to keep it open.
Weekly R Challenge, Entry #5
I made my first Shiny app! Shiny is an R package that helps with building interactive web applications (apps) directly from R. I’ve been wanting to get some experience with this for a long time now, but until last week I couldn’t find the time to do it. Last week I had a mild cold, so while I was in bed, covered in few layers of clothing and a blanket, I listened through the Shiny video tutorials. Then, on Friday (last week), I was feeling better, so I thought it’s time to actually open the R Studio and get going with the Shiny. I started with learning how to write inline Shiny objects(?)/apps in R Markdown document (see here), but I wasn’t really happy with the formatting options. Then, on Monday (yesterday), I decided that I am ready to make my first real Shiny app. So, I did that! Today, I only had to figure out how to launch it on the shinyapps.io. I tracked my hours:
- 1:59 h for the inline shiny in R Markdown (Fri, 08 Feb)
- 4:38 h for my 1st Shiny app (see below) (Mon, 11 Feb)
- 1:07 h for figuring out the shinyapps.io (Tue, 12 Feb)
So, before I get into why I chose this to be my 1st Shiny app, I’ll list all the links to the help materials I used:
- Main reference: Learn Shiny from R Studio (video tutorials + lots of other help)
- Interactive Web Apps with shiny Cheat Sheet
- Application layout guide + some of the other articles from this page
- Chapter 19 Shiny Documents from “R Markdown: The Definitive Guide” by Yihui Xie, J. J. Allaire, and Garrett Grolemund
- Getting started from “shinyapps.io user guide” by the shinyapps.io team
I also scrolled through some of the Shiny app showcases, just to get a general idea of what are the capabilities. I spend a lot of time figuring out how to read some data into Shiny app… and not so much the how, but where to write it. Currently, its within the plot rendering section, but I’m pretty sure that’s not the most appropriate place. I still have to learn more in order to know what I’m doing…
Here is how my 1st Shiny app looks like (I’ll provide a link to it at the end):
What was the purpose of this exercise?
Last two years were very dynamic and probably I will be talking about my experiences, good or bad, for many years to come… This particular Shiny app would have been really helpful for one of my Environmental Modeling Tutorials (I’ll add a link once I’ve uploaded all my teaching materials). One of the exercises was asking the students to explore how the function arguments affect the locally fitted polynomial surface (loess) and to reflect on their observations (and submit their observations). I thought this would focus students’ attention on the importance of parameter choice. However, I wasn’t completely satisfied with the “learning outcomes” (to use the terminology). It seemed that most students were doing it very mechanically, submitting all the plots they have made (which wasn’t really necessary), and not really reflecting on what happens and what is the purpose of it all. It felt very much like: “look, I did what you asked me to do.” Now I think, if the exercise wasn’t about coding (changing parameters in a line of code), but entirely focusing on the analysis of the results, then the outcome would have been better. I also think this Shiny app would have made my life easier, but also my students would have been less bored by the repetition. I was very much focused on how the majority was learning (not the few exceptional cases, who were probably bored because it was too easy), so I felt like I really failed this part.
Why this dataset?
Again, I used this dataset for two of my Tutorials, so it was easier to just keep using it. The question is why did I use it for my Tutorials. I am fascinated with everything about Japan! This dataset was interesting to me for two reasons: 1) it is compiled from historical documents where the sakura full bloom date was mentioned (diaries of emperors etc), and 2) it was used for reconstructing May temperatures in Kyoto. It was relevant, but also it made me imagine all the blooming trees and everyone who goes out to admire the blooming trees. I thought that a lot of people could relate to this, also it was about something happening in Asia (not SE, but still!).