Raspberry Pi and R

R

[Stephen] picked up a Raspberry Pi to do a little hardware hacking and add a blinking LED to the many feathers in his software development hat. He picked up an analog to digital converter and a temperature sensor that would serve him well in a few projects he wanted to put together, including a weather station and a small Pi-controlled home brewing setup. He ended up not liking Python, and didn’t like the C-ness of wiringPi. He’s a scientist, so he’s most comfortable with R and Matlab. Of course, playing around with a R and a Raspberry Pi means replicating his sensor-reading code in R.

[Stephen] put together a neat little package that will allow him to read his sensors over an SPI bus with his Raspberry Pi. Yes, this functionality can easily be duplicated with Python, but if you’re looking to generate beautiful graphs, or just do a whole lot of statistics on something, R is the tool you need.

It’s a cool project, even if it is only measuring the temperature. Using R for the nerd cred isn’t bad, either.

Comments

  1. ggea says:

    Do. Not. Use. MATLAB for numerical computations because it suffers from floating point issues. Mathematica or cLISP is way better and more precise.

  2. poeticoddity says:

    It’s always good to see R get some love, and this is an interesting application.

  3. fho says:

    Actually pythons matplotlib is damn slow when you are looking for >10fps. Otoh this project will most probably not be about fast plotting.

    I’d be interested what he disliked about python _and_ C … last time I checked out R it was very C-like. With some operators inspired by math for good measure.

    • spbecker says:

      So you perhaps saw my reply to the comment below, however I’ll clarify on the C and Python thing. If you read my original Google+ post, I only said I disliked Python (for some reason I’ve always found the look and feel of Python kind of icky when I’ve played around with the code).

      Concerning C, in truth I’ve never programmed in it, so I don’t like or dislike it. In fact, I had originally intended on trying to do a full C implementation of the sensor reading+COSM function to try to make it very fast as compared to the Adafruit python example and also as a first project to get me more familiar with C. However I was at a loss to how I would send data to COSM this way, and thus only used C in this project as an interface with libwiringPi. I ripped out the readadc function from the Raspberry Pi hobbyist blog linked in my G+ post, and compiled it into a small library linked with R (which is then loaded into memory in my R script), and use it to talk to the A to D with R’s .C function.

  4. Alex says:

    Haven’t seen it implemented on a Raspberry Pi yet, but I think you can make better looking charts with matplotlib than with R. There are also some excellent stats libraries.

    Not saying there aren’t legitimate reasons to use R and Matlab (the most important being familiarity), but I think python is also a good choice.

    • spbecker says:

      So I’m the Stephen who wrote the R sensor code referred to in this post.

      My reasons for using R go back about ten years ago while working on my dissertation. I experimented extensively with several different integrated plotting and data analysis packages, including matplotlib, Matlab, Octave, R, SPSS, and SAS. I decided I liked R the best out of all of these because I found the language easy to learn, it did everything I needed, and I really liked the tight integration of the plotting utilities that didn’t feel like an afterthought or kluged-on library.

      Since then I’ve used R for many things for which there were probably better solutions simply because I’m familiar with it. It works for me, and I can make it do useful things without too much effort.

    • Velli says:

      If you’re bloody-minded enough, R with ggplot gives you very granular abilities to make the charts you want.

      I hadn’t even considered using R with RaspPi. With some low-power peripherals and enough silicone, that might be a great package for the “event epis” to pack into the worst field conditions.

  5. afasdlfkjasdf says:

    trololololoooo R in an Rasperry. U MAD BRO :D
    but probably the best solution ;D

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 93,711 other followers