dmwiig
Posts: 24
Joined: Tue Feb 25, 2014 1:06 am

Using R with the Pi

Thu Feb 27, 2014 11:18 pm

I just got my Pi up and running as a Wordpress server and am now in the process of installing the R statistical programming base package. I hope to use to the Pi as a platform for R work and package development. If you are interested in this type of project stop by and join the discussion at raspberrypiandr.no-ip-org/wordpress.

DougW

dmwiig
Posts: 24
Joined: Tue Feb 25, 2014 1:06 am

Re: Using R with the Pi

Thu Feb 27, 2014 11:20 pm

Correction: the url for my Wordpress site is raspberrypiandr.no-ip.org.

DougW

dmwiig
Posts: 24
Joined: Tue Feb 25, 2014 1:06 am

Re: Using R with the Pi

Mon Mar 03, 2014 11:13 pm

I have successfully installed R version 2.15 on my Pi using the package manager that is part of the Raspian distribution. This version works fine and seems very stable on Raspian. I have not as yet tried installing version 3.xx to see if it also works. I am going to try install the RStudio IDE on Raspian but have not yet found the time to do so. I am also hosting a Wordpress site on my Pi devoted to providing information on both R and the Pi. It is found at http://raspberrypiandr.no-ip.org/wordpress.

I would love to hear about your projects and interests in using R and the Pi in an educational setting. I teach social science statistics and the university level and am very interested in the potential of this type of open source software as a research and learning tool in the classroom.

DW

mitchbu
Posts: 11
Joined: Sun Jul 14, 2013 12:00 pm

Re: Using R with the Pi

Mon Jun 16, 2014 12:45 pm

Hey Doug,

I am very happy to find someone with the same idea as me. I have a little project in mind using R and raspbian.
Roughly, what I want to do is the following:
- R on raspbian runs a script automatically every saturday night and compiles a PDF report about the output (weekly data) and uploads it to my google drive or dropbox or wherever.
- On Sunday morning I can access the report from my android tablet read the updated info together with a coffee :D

Anyways, these ideas are way off in the future, since I am already struggling with basics. R in general is not the problem since I use it almost daily. On my raspbian so far I got XBMC running and working and I am super glad with it.

However, I managed to install R using

Code: Select all

sudo apt-get install r-base
But when I want to install more packages, for instance "foreign", I am already running into troubles.

Code: Select all

>  install.packages("foreign")
Installiere Paket(e) nach '/usr/local/lib/R/site-library'
(da 'lib' nicht spezifiziert)
--- Bitte einen CRAN Spiegel für diese Sitzung auswählen ---
Fehler in if (ht < length(choices)) { :
  Fehlender Wert, wo TRUE/FALSE nötig ist
Zusätzlich: Warnmeldung:
In tcltk::tk_select.list(choices, preselect, multiple, title) :
  NAs durch Umwandlung erzeugt
>
I would also love to install Version 3.x.x as mentioned on this website http://cran.r-project.org/bin/linux/debian/README.html but adding deb http://http://cran.r-mirror.de/bin/linux/debian wheezy-cran3/ to the file /etc/apt/sources.list does not work. I have to mention that LINUX installations still give me a headache each time and I need to have a step-by-step procedure.

You refer to you blog, but I cannot access the website:
http://raspberrypiandr.net/wordpress
http://raspberrypiandr.no-ip.org/wordpress/

The pages read:
Neither /etc/wordpress/config-raspberrypiandr.no-ip.org.php nor /etc/wordpress/config-no-ip.org.php could be found.
Ensure one of them exists, is readable by the webserver and contains the right password/username.

Additionally, I would love to work with R-Studio on raspbian, but this is not required as I will do the coding on my PC and just upload the script to the pi.

Since it looks like you really know what you are doing, I would appreciate it a lot if you could give me some clues about to solve my issues.

Thanks a lot in advance,
Michael

lvphj
Posts: 2
Joined: Sun Jul 06, 2014 6:01 pm

Re: Using R with the Pi

Sun Jul 06, 2014 8:00 pm

I was having the same problem as Michael when installing the foreign package for R on my RaspberryPi (Raspbian Wheezy). After starting R and entering install.packages(foreign), I received a message saying that:

Code: Select all

package ‘foreign’ is not available (for R version 2.15.1)
Previous versions of the foreign package are available at http://cran.r-project.org/src/contrib/Archive/foreign/ – so I decided to compile the library from source. These are the steps I followed:

1. Create two new nested directories in your home folder that will be used to store the libraries (and the downloaded archive):
i. ~/lib/R/library
ii. ~/lib/R/archives

2. Using a text editor, create a text file called .Renviron and save it in your home directory. (N.B. This file name begins with a full stop and, therefore, is invisible.) R looks for this file when it first starts up. To ensure that installed packages are, by default, saved to ~/lib/R/library, the text file should contain the line:

Code: Select all

R_LIBS="~/lib/R/library:${R_LIBS}"
3. By trawling through the foreign archive files, I found that the last version to be compatible with R 2.15.1 is foreign 0.8.54. Therefore, downloaded the file foreign_0.8-54.tar.gz and saved it in ~/lib/R/archives.

4. Start R from the command line by entering:

Code: Select all

$ R
5. At the R prompt, enter:

Code: Select all

> install.packages("~/lib/R/archives/foreign_0.8-54.tar.gz”, repos=NULL, type="source")
6. Load the foreign library at the R prompt using:

Code: Select all

> library(foreign)
That's it. Seems to work OK. I managed to import a very simple Stata .dta file with no problems but I haven't had chance to text it extensively yet.

xinkaiwang
Posts: 2
Joined: Thu Jan 21, 2016 6:16 am

Re: Using R with the Pi

Thu Jan 21, 2016 6:32 am

hi Michael,
I'm new to this area. Not 100% sure why you want to use pi to function as a server (like do some data processing as a daemon job). In my opinion, I don't mind to have a real X86 server to do this job. A EC2 t2 micro instance should be good enough. I think pi is special because it's small and light-weight and powerful. So it's really suitable to run machine learning algorithms on it and create smart 4WD or robots. For example how about a self-balancing 2-weel robot with visual machine learning? He can see stuff and learn from what he see, for instance, recognize you and following you; remember the path and go roaming by him-self?

BTW, the workpress web-site seems to be down. I wish I can find more people have similar visions like me.

xinkai

jsraadt
Posts: 1
Joined: Thu Aug 31, 2017 1:54 am

Re: Using R with the Pi

Thu Aug 31, 2017 1:57 am

The "foreign" package in R is already installed. Just use

Code: Select all

require(foreign)
or

Code: Select all

library(foreign)
to initialize the package.

wardster41
Posts: 16
Joined: Tue Jan 30, 2018 6:58 pm

Re: Using R with the Pi

Sat Jun 30, 2018 10:04 pm

Hi,
I guess that Doug W has abandoned his Wordpress site for discussing the use of R on the Pi architecture.

I'd like to suggest that the Raspberry Pi Foundation try to make a connection with the folks developing GUI interfaces to R to see about supporting one (or more) of them on the Pi. I think this would be a nice complement to having Mathematica installed on the Pi.

One R-GUI that has been around a while is R Commander, a newer one is Blue Sky Statistics. The latter is a commercial enterprise with a free version, the former is, I believe, free. R is a language oriented to statistical processing, including machine learning. Ability to code in R is a sought-after skill in today's marketplace. I think this would be a useful addition to the suite of software available to users of the Pi architecture. Especially useful for those of us who, in addition to using Pi boards are running the Raspberry Pi Desktop on an x86 machine. We do not have Mathematica and could benefit from having R.

I have been able to load a version of R using the Cantor interface, but that now seems to be iffy (if not abandoned). Having a real GUI front-end would be very useful.
Debian with Raspberry Pi Desktop (I like to call it RaPIDx86) is giving new life to my old Samsung NC-10 netbook. Using VNC to connect to a Pi-Zero-W on my network. Have a PI Model 2 B+ running a file server on the same network. Great hobby!

User avatar
Ronaldlees
Posts: 293
Joined: Sat Apr 16, 2016 4:28 pm
Location: North Carolina, US
Contact: Website

Re: Using R with the Pi

Sun Jul 01, 2018 3:51 pm

wardster41 wrote:
Sat Jun 30, 2018 10:04 pm

... I have been able to load a version of R using the Cantor interface, but ...
Thanks for the post. Wish this forum had a "thanks" button. Would save space on the forum database. Anyway, you're right - would be great complement.
I am the Umbrella man: IR3/IR5 UV a/b/c OTS specs: break free, live life. Note that red cannot be seen with IR lenses, so cross at stop lights only on white walk signals, don't drive or operate machinery with lenses on, and don't use in low light.

Return to “Teaching and learning resources”

Who is online

Users browsing this forum: No registered users and 2 guests