Site icon R-bloggers

Fun with the Raspberry Pi

[This article was first published on mages' 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.
Since Christmas I have been playing around with a Raspberry Pi. It is certainly not the fastest computer, but what a great little toy! Here are a few experiences and online resources that I found helpful.

Setup

Initially I connected the Raspberry Pi via HDMI to a TV; together with keyboard, mouse and an old USB Wifi adapter. Everything worked out of the box and I could install Raspbian and set up the network.

HDMI to VGA

Using an old VGA computer monitor via an adapter required changes to the file /boot/config.txt. You can find the parameters that match your monitor on Raspberry Pi StackExchange. In my case I had to set:
hdmi_group=2
hdmi_mode=35 # 1280x1024 @ 60Hz

Remote Access

But who needs a monitor when you can access the Pi remotely anyway? The command ifconfig tells me the local IP address of the Raspberry Pi.

With XQuartz on my Mac running I can connect to the Raspberry Pi via ssh with the X session forwarded:
ssh -X pi@your.ip.address.here
However, the performance is a bit sluggish and online comments suggest to use VNC instead. Nothing easier than that, install the VNC server on the Pi and use Screen Sharing on your Mac to access the Pi. Mitch Malone has a great post on this subject. Following the VNC setup on the Raspberry Pi I can type:
vnc://pi@your.ip.address.here:5901
into Safari and that will bring up the Screen Sharing App; see screen shot below.

AirPrint and AirPlay

Ok, let’s give the Pi something to do: Rohan Kapoor explains how to set up the Raspberry Pi as a print server with AirPrint.

How about AirPlay as well? Follow Thorin Klosowski’s steps on Lifehacker and you can stream music from your iOS devices to the Raspberry Pi’s audio out.

Mathematica and R



Just before Christmas Stephen Wolfram announced that Mathematica would be made freely available for the Raspberry Pi. I had used Mathematica a little at university and was curious to see it on the Pi. Alex Newman posted the installation instructions on the Wolfram community site. It is as simple as:
sudo apt-get update && sudo apt-get install wolfram-engine
As a little toy example I run Paul Nylander’s Mathematica code for a Feigenbaum diagram:

Surprisingly, it took about 3.5 minutes to run. Curious to find out if my old R routine would run faster I installed R on my Pi:
sudo apt-get install r-base
and adapted the code to match the parameters of the Mathematica routine (well, so I think):

The R code finished after about 10 seconds. Surely, there must be ways to speed up the Mathematica code that I have to investigate.

To leave a comment for the author, please follow the link and comment on their blog: mages' 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.