In this page, We shall describe the installation process for RStudio Desktop/Server on Raspberry Pi 2 or 3(Raspbian Jessie with PIXEL).
RStudio Desktop on Raspberry Pi 3
RStudio Server on Raspberry Pi 3

Requirements

First of all we need to increase the amount of swap space and to change the default sh from dash to bash.

sudo su
service dphys-swapfile stop
nano /etc/dphys-swapfile
	# The default value of CONF_SWAPSIZE in Raspbian is 100.
	# We will need to change this to: (empty) ,1024, and so on.
	# After installing RStudio, it would be better to restore
	# the value of CONF_SWAPSIZE to the initial value in order
	# to stand a micro SD card long use.
service dphys-swapfile start
dpkg-reconfigure dash

Installing RStudio Server

Installation of RStudio Server is the same as that of this page. We shall quote exactly from the page except that we have changed 'downloads' to 'Downloads' , a filename of compiler.jar and a directory of running 'make install'. [We supplement steps with installing python-dev.(2017.3.14)]
sudo su
apt-get update
apt-get upgrade -y
apt-get install -y git r-recommended python-dev
cd /home/pi/Downloads/
git clone https://github.com/rstudio/rstudio.git
cd /home/pi/Downloads/rstudio/dependencies/common/
./install-common
cd /home/pi/Downloads/rstudio/dependencies/linux/
./install-dependencies-debian

#saw java 6 was not installed. installed v7
apt-get install -y openjdk-7-jdk

#tried to make install, got an error about dictionaries not installed and rerun install-dependencies
cd /home/pi/Downloads/rstudio/dependencies/common/
./install-common

#tried to make install, hangs at "ext:" so I tried manually installing pandoc, which should have been installed earlier, but apparently was not
apt-get install -y pandoc

#tried to make install, hangs at "ext:" so I tried installing the latest GWT compiler
cd /home/pi/Downloads
wget http://dl.google.com/closure-compiler/compiler-latest.zip
unzip compiler-latest.zip
rm COPYING README.md compiler-latest.zip
mv closure-compiler-v20170218.jar /home/pi/Downloads/rstudio/src/gwt/tools/compiler/compiler.jar

#build and install works!
cd /home/pi/Downloads/rstudio/
#remove build if exists
rm -r ./build
mkdir build
cd build
cmake .. -DRSTUDIO_TARGET=Server -DCMAKE_BUILD_TYPE=Release
make install
# Additional install steps
sudo useradd -r rstudio-server
sudo cp /usr/local/lib/rstudio-server/extras/init.d/debian/rstudio-server /etc/init.d/rstudio-server
sudo chmod +x /etc/init.d/rstudio-server 
sudo ln -f -s /usr/local/lib/rstudio-server/bin/rstudio-server /usr/sbin/rstudio-server
sudo chmod 777 -R /usr/local/lib/R/site-library/

# Setup locale
sudo apt-get install -y locales
sudo DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
#echo 'export LANG=en_US.UTF-8' >> ~/.bashrc
#echo 'export LANGUAGE=en_US.UTF-8' >> ~/.bashrc

## Clean the system of packages used for building
#sudo apt-get autoremove -y cabal-install ghc openjdk-7-jdk pandoc libboost-all-dev
#sudo rm -r -f ~/rstudio-$VERS
#sudo apt-get autoremove -y
Finally, according to [5], we shall install pandoc-citeproc and remove files as follows.
sudo apt-get install pandoc-citeproc
sudo rm /usr/local/lib/rstudio-server/bin/pandoc/pandoc
sudo rm /usr/local/lib/rstudio-server/bin/pandoc/pandoc-citeproc
#Before starting the server, we need to reload daemon.
sudo systemctl daemon-reload

# Start the server
sudo rstudio-server start

# Go to localhost:8787

Installing RStudio Desktop

The first half of Installation steps are the same as RStudio Server.
sudo su
apt-get update
apt-get upgrade -y
apt-get install -y git r-recommended python-dev
cd /home/pi/Downloads/
git clone https://github.com/rstudio/rstudio.git
cd /home/pi/Downloads/rstudio/dependencies/common/
./install-common
cd /home/pi/Downloads/rstudio/dependencies/linux/
./install-dependencies-debian

#saw java 6 was not installed. installed v7
apt-get install -y openjdk-7-jdk

#tried to make install, got an error about dictionaries not installed and rerun install-dependencies
cd /home/pi/Downloads/rstudio/dependencies/common/
./install-common

#tried to make install, hangs at "ext:" so I tried manually installing pandoc, which should have been installed earlier, but apparently was not
apt-get install -y pandoc

#tried to make install, hangs at "ext:" so I tried installing the latest GWT compiler
cd /home/pi/Downloads
wget http://dl.google.com/closure-compiler/compiler-latest.zip
unzip compiler-latest.zip
rm COPYING README.md compiler-latest.zip
mv closure-compiler-v20170218.jar /home/pi/Downloads/rstudio/src/gwt/tools/compiler/compiler.jar

#build
cd /home/pi/Downloads/rstudio/
#remove build if exists
rm -r ./build
mkdir build
cd build
For the second half, we need to install some packages and to edit some files.
apt-get install -y qt5-default libqt5svg5-dev libqt5sensors5-dev libqt5webkit5-dev libqt5xmlpatterns5-dev qtpositioning5-dev
mv /root/Qt5.4.0/5.4/gcc/bin /root/Qt5.4.0/5.4/gcc/bin_orig
mv /root/Qt5.4.0/5.4/gcc/lib /root/Qt5.4.0/5.4/gcc/lib_orig
ln -s /usr/lib/arm-linux-gnueabihf/qt5/bin /root/Qt5.4.0/5.4/gcc/bin
ln -s /usr/lib/arm-linux-gnueabihf /root/Qt5.4.0/5.4/gcc/lib
nano /root/Qt5.4.0/5.4/gcc/lib/cmake/Qt5Core/Qt5CoreMacros.cmake
	#change COPY_ONLY to COPYONLY
	#
	#sed -i -e s/COPY_ONLY/COPYONLY/g /root/Qt5.4.0/5.4/gcc/lib/cmake/Qt5Core/Qt5CoreMacros.cmake
nano /home/pi/Downloads/rstudio/src/cpp/desktop/CMakeLists.txt
	# change "cmake_policy(SET CMP0020 OLD)" to "cmake_policy(SET CMP0043 OLD)"
	#sed -i -e s/CMP0020/CMP0043/g /home/pi/Downloads/rstudio/src/cpp/desktop/CMakeLists.txt

cd /home/pi/Downloads/rstudio/build
cmake .. -DRSTUDIO_TARGET=Desktop -DCMAKE_BUILD_TYPE=Release
make -j3 install &> install_output

#According to [5]
sudo apt-get install pandoc-citeproc
sudo rm /usr/local/lib/rstudio/bin/pandoc/pandoc
sudo rm /usr/local/lib/rstudio/bin/pandoc/pandoc-citeproc

#When trying to run, saw : libEGL warning: DRI2: failed to authenticate
#According to [6], make the following symbolic links.
#(See  Addendum below.)

#sudo apt-get install chromium-browser
LIBEGL=`sudo find /usr/lib/chromium-browser -name libEGL.so`
LIBGLES=`sudo find /usr/lib/chromium-browser -name libGLESv2.so`
sudo ln -sf $LIBEGL /usr/lib/arm-linux-gnueabihf/libEGL.so
sudo ln -sf $LIBEGL /usr/lib/arm-linux-gnueabihf/libEGL.so.1
sudo ln -sf $LIBGLES /usr/lib/arm-linux-gnueabihf/libGLESv2.so
sudo ln -sf $LIBGLES /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2

#How to run RStudio Desktop
/usr/local/lib/rstudio/bin/rstudio
We can use Raspberry Pi Menu as follows.

Addendum

"In this release we are shipping an experimental OpenGL driver for the desktop which uses the GPU to provide hardware acceleration."([8]). If we enable this driver, then we can use the original so files and the warning "libEGL warning: DRI2: failed to authenticate" will disappear. Instead, we will see another warning "MESA-LOADER: failed to retrieve device information". However, this warning will be fixed in libdrm 2.4.73 according to [9].

References

  1. Native Build of Qt 5.4.1 on a Raspberry Pi - Qt Wiki(accessed February 25, 2017).
  2. raspbian - Error while trying to compile RStudio - Raspberry Pi Stack Exchange(accessed February 25, 2017).
  3. [QTBUG-44637] Qt5CoreMacros.cmake uses COPY_ONLY instead of COPYONLY for configure_file() - Qt Bug Tracker(accessed February 25, 2017).
  4. CMP0043 — CMake 3.0.2 Documentation(accessed February 25, 2017).
  5. RStudio on RaspberryPi 3 | R-bloggers(accessed February 25, 2017).
  6. raspbian - Qt applications don't work due to libEGL - Raspberry Pi Stack Exchange(accessed February 28, 2017).
  7. RStudio - RStudio Server and Shiny(accessed February 28, 2017).
  8. Another new Raspbian release - Raspberry Pi(accessed March 18, 2017).
  9. Bug #1656930 " OpenGL applications warns “MESA-LOADER: failed to...” : Bugs : Raspbian(accessed March 18, 2017).

日本語(Japanese)
This page was last modified on 21 March 2017.