Site icon R-bloggers

A Gadget for tidyr

[This article was first published on Mango Solutions » R Blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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!

 

To leave a comment for the author, please follow the link and comment on their blog: Mango Solutions » R Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.