Analyzing Nike+ using R

[This article was first published on macsci, 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.

logonike
A couple of weeks ago, I finally took up running seriously. To keep myself motivated — especially on dark winter nights — I bought the Nike+ iPod sports kit. The sports kit was developed by a partnership of Nike and Apple, and consists of a tiny accelerometer that you attach to one of your shoes (according to Nike it should go in a special built-in pocket of your special Nike+ compatible shoe, but there are of course plenty of other solutions), and a receiver you attach to your iPod. The accelerometer sends its data to your iPod, which in turn can tell you how far you ran and how far you still have to go. So far so good, but what you probably want to do is to analyze the data you have painfully gathered. And the way to do that, according to apple and nike, is to let iTunes send your data to the nikeplus website. This website is heavily flash-based, slow and only shows general trends — it doesn’t let you touch your raw data. And that is exactly what I wanted. A couple of existing programs give you slightly better control over your data (e.g., Runner’s Log, TrailRunner), but none of them did cater to my needs.

To solve this I decided to write an R-script: how to better analyze data than by using R? Fortunately, the running data is stored in xml files on your iPod, which makes life easy. The script starts by copying new .xml files from a connected iPod (if there is one) to your hard disk, and parses the contents of the new files. Then, it displays the speed and pace over your last run, and graphs of speed, pace and distance of all your runs to date. For example:

speed
distance

Of course, as the script gives you access to the raw data, you can do with it what you like.

Training

The last thing the current script does is importing a csv training schedule (e.g., 12/30/08,2,3.218688
– date/mile/km). It displays the distance you have to run each day, and shows what you have already managed:

training

Furthermore, it creates two iCal calendar files, one for your schedule, and one for what you have done. These are moved to a directory, to which I connected a folder action applescript for cyberduck (see these examples), that automatically uploads the calendars to my website. Finally, I use iCal to subscribe to those calendars, letting it display what I still have to do and what I have done.

If you would like to try it out, you can download my script here, if you have any questions about the script, please feel free to send me and email.

To leave a comment for the author, please follow the link and comment on their blog: macsci.

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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)