By Aimee Gott
About a month ago I wrote a review of the Shiny Developer Conference and I mentioned Shiny Gadgets, my new favourite thing in R. Over the last month I have played about with them and finally got to share my enthusiasm with users at Manchester R last night. In particular I showed off a gadget that I have put together for interactive tidying of data, specifically a way to interactively use the gather function form tidyr.
Changing the shape of data is something that I always found tricky. I could never remember what needed to go where in my reshape/reshape2 formula to get the data that I wanted. It was generally luck that got me to the right format. Thankfully for me Hadley Wickham then launched a new version of these packages, tidyr, and the notation suddenly made so much more sense. I have been saved from hours of trial and error and I now (almost) always get the data that I want.
But that isn’t the case for everyone. When I am teaching tidyr I still find that until you have been able to show people what the code does they don’t get a good feel for what is going on. With reshape there was the helpful UI, reshapeGUI that allowed for interactive data manipulation, but this didn’t exist for tidyr. What a great candidate for a gadget!
Less than 70 lines of shiny gadget later (including my excessive commenting) and I had a gadget that picks up data in your session, lets you set the arguments and see what your data is going to look like at the end. When you are “Done” it will even give you the line of code so you can then do it yourself.
It’s still a work in progress but feedback last night would suggest that it’s not just me that finds this tool handy. You can get the app in the tidyshiny package on MangoTheCat’s GitHub page and it’s all set up to work with RStudio addins, if you are using the latest version of RStudio. Let us know how you get on and what else you would like to see in this tool (separate and spread are already on my todo list!).
If you haven’t seen gadgets yet, Joe Cheng’s talk from EARL 2015 is now available here so you can see him talking about an early version of gadgets and I will be presenting more from the Shiny Dev Conference at LondonR next month!