forked from pachadotdev/r-packages-ubuntu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.sh
74 lines (57 loc) · 2.17 KB
/
configure.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
echo "This script will install R (if needed) and configure bspm on your system."
# ask to continue or exit
read -p "Do you want to continue? (y/n) " -n 1 -r
# stop if not running as sudo
if [ "$EUID" -ne 0 ]
then echo "Please run as sudo"
exit
fi
# add an updated R source to the system manager
add-apt-repository ppa:marutter/rrutter4.0
# add a binary R packages source to the system manager
add-apt-repository ppa:c2d4u.team/c2d4u4.0+ # R packages
# update the system (ask if ok)
apt update && apt upgrade
# install dependencies
apt install python3-{dbus,gi,apt}
# install R
apt install r-base
# ask if the user to install development tools
echo "Do you want to install development tools (i.e, to build R packages)?"
select yn in "Yes" "No"; do
case $yn in
Yes ) apt install r-base-dev; break;;
No ) break;;
esac
done
echo "Do you want to install Git?"
select yn in "Yes" "No"; do
case $yn in
Yes ) apt install git; break;;
No ) break;;
esac
done
echo "Do you want to install RStudio?"
select yn in "Yes" "No"; do
case $yn in
Yes ) curl -sS https://apt.pacha.dev/pacha.gpg | gpg --dearmor | tee /etc/apt/trusted.gpg.d/pacha.gpg >/dev/null && echo "deb https://apt.pacha.dev ./" | tee /etc/apt/sources.list.d/pacha.list > /dev/null && apt update && apt install rstudio; break;;
No ) break;;
esac
done
# install bspm as a system package from CRAN
Rscript -e 'install.packages("bspm", repos="https://cran.r-project.org")'
# enable it system-wide
# echo "bspm::enable()" | tee -a /etc/R/Rprofile.site
# enable it for the user
# echo "bspm::enable()" | tee -a ~/Rprofile.site
# ask the user to chose between a system-wide or user-wide activation
echo "Do you want to enable bspm system-wide (all users) or user-wide (only you)?"
select yn in "System-wide" "User-wide"; do
case $yn in
"System-wide" ) echo "bspm::enable()" | tee -a /etc/R/Rprofile.site; break;;
"User-wide" ) echo "bspm::enable()" | tee -a ~/Rprofile.site; break;;
esac
done
# send msg to ask to test it
echo "Please close and reopen RStudio and test the setup by running 'install.packages("ggplot2")' in R (or any other package)"