MoreNotesToSelf

Technology, Finance, and Life

Posts Tagged ‘yfd’

ggplot2, plyr, and your.flowingdata

Posted by DK on November 3, 2009

The previous post described how I went about cleaning up some yfd data using Python and numpy. I have no doubt it can be done in fewer lines of code, but I think the post described how useful it can be to manipulate arrays rather than looping through everything. With the data cleaned up, I hoped to visualize my newborn son’s sleep schedule. I recently received an example that does the same thing as my python code, but in 3 lines! It uses R, ggplot2, and plyr. A few more lines can generate pretty plots like this (box plot of sleep length in hrs vs. start time):

 

 

As the plot above shows, my son doesn’t sleep a helluva lot during the day. The boxplot also illustrates how volatile his night sleeping has been. This tells me I need to do a better job of getting the boy to nap during the day in hopes of producing longer and more restful sleep periods at night.

 

While Python has been my gateway drug into the world of programming, I’ve been itching to try out a plotting package based on R, ggplot2. R is a popular language in the statistics community that has enjoyed some good press recently. Anyway, my little sleep duration project seemed perfect for some R exploration.

 

After searching around on the Interweb, I managed to write some broken R code that didn’t really do what I wanted. Luckily, Hadley Wickham (the author of plyr and ggplot2) took pity on me and offered up some example code to point me in the right direction. I was shocked at the efficiency of the example, particularly given all the wrangling I had to do in python. Now, just for the record, I’m not making any statements about R vs. Python. Hadley obviously created plyr and ggplot2 to make R easier to use, and I imagine the same could be (or already has been) done for python. I just lack the experience and education to know!

 

Anyway, plyr and ggplot2 are very nice libraries that offer yet more reasons to learn R. Thank you Professor Wickham! Between python and R, I’ve got to believe one can slice and dice almost anything. If I could only get rpy2 working…

 

Advertisements

Posted in R, Tech | Tagged: , , | Leave a Comment »

Use your.flowingdata.com…for the children

Posted by DK on September 26, 2009

Personal data capture is a meme that’s gaining momentum. Products such as Nike+ and, more recently, Fitbit target those who would like to monitor daily exercise and other activities. Websites that allow users to manually track how they use their time have also started to pop-up. For those of us that like to procrastinate, these monitoring tools can help by providing regular feedback. Watching a little line move in the right direction can be pretty motivating.

Of course, I haven’t used any of these services. For myself.

Nevertheless, as a new father, I’ve found that your.flowingdata.com is an easy and useful way to track the activities of my newborn son! The service uses tweets to capture pretty much any kind of data you’d care to record. There are electronic products (Itsbeen, basically a stopwatch on steroids) that help new parents keep track of when the baby last slept, ate, poo’ed, etc. They do not, however, capture that data for analysis. My wife and I would like to see the historical data to see if we can tease out some insights about our son (e.g., how much sleep does he need before he gets cranky?). We tried using an iPhone app called Blogger that helps parents keep track of these things, but it wasn’t immediate enough. We ended-up writing things down on the nursery mirror with a dry erase pen but I really wanted something that could track things via a single button press. By the time I’ve finished dodging multiple salvos of pee and poo, multiple diaper changes due to said peeing and pooing, spit-up, puking, and sundry other lovely activities (a testament to how much I love you, boy), I can’t remember anything that’s happened in the last five minutes, let alone the last hour or two. So far, your.flowingdata.com has been the answer.

your.flowingdata.com (‘yfd’) is a service based on Twitter. Users send direct messages to ‘yfd’ and can visit the site for simple visualizations. Users can also download tab-delimited files with all the data. But wait, there’s more! One kind soul also created a simple yfd iPhone application that allows users to send an update (e.g. ‘d yfd gnight’) via a single button press. Each button can be customized as well. I have no use for Twitter, but yfd got me to open an account. We’re still figuring out what we want to record, but the service’s flexibility and ease-of-use makes it much more likely we’ll actually use it.

yfd isn’t perfect. There’s no built-in way to, for example, calculate the time that has elapsed between two actions (e.g. going to sleep and waking up). One has to download the data and calculate durations manually (or create a script to do it). There are other visualizations available, though. As I mentioned, however, I find it’s much more important to make it easy to capture data for something like this. If it’s a pain to capture the data, there won’t be anything to analyze on the back-end anyway.

So, if you have absolutely no interest in personal fitness, time tracking, etc., you may want to check-out your.flowingdata.com…for the children.

Posted in Life, Tech | Tagged: , , | Leave a Comment »