Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install R and RStudio on Ubuntu 19.10 with essential libraries for data science. Based on pachamaltese/r_ubuntu_17_10.sh (for Ubuntu 17.10). Note: You need to make sure the default library location - /usr/local/lib/R/site-packages - is writable .
# Add repo to install the last R
sudo apt install apt-transport-https software-properties-common
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu eoan-cran35/'
# Install R
sudo apt update
sudo apt install gdebi libxml2-dev libssl-dev libcurl4-openssl-dev libopenblas-dev r-base r-base-dev
# Install RStudio
cd ~/Downloads
wget https://download1.rstudio.org/desktop/bionic/amd64/rstudio-1.2.5001-amd64.deb
sudo gdebi rstudio-1.2.5001-amd64.deb
# I really don't know if this is necessary anymore.
test -r ~/.bash_profile && printf '\nexport QT_STYLE_OVERRIDE=gtk\n' | sudo tee -a ~/.bash_profile
test -r ~/.zshrc && printf '\nexport QT_STYLE_OVERRIDE=gtk\n' | sudo tee -a ~/.zshrc
printf '\nexport QT_STYLE_OVERRIDE=gtk\n' | sudo tee -a ~/.profile
# Install common packages
R --vanilla << EOF
install.packages(c("tidyverse","data.table","dtplyr","devtools","roxygen2","bit64","readr"), repos = "https://cran.rstudio.com/")
q()
EOF
# Install TDD packages
R --vanilla << EOF
install.packages("testthis")
q()
EOF
# Export to HTML/Excel
R --vanilla << EOF
install.packages(c("htmlTable","openxlsx"), repos = "https://cran.rstudio.com/")
q()
EOF
# Blog tools
R --vanilla << EOF
install.packages(c("knitr","rmarkdown"), repos='http://cran.us.r-project.org')
q()
EOF
sudo apt install python-pip
sudo apt install python3-pip
sudo -H pip install markdown rpy2==2.7.1 pelican==3.7.1
sudo -H pip3 install markdown rpy2==2.9.3 pelican==3.7.1
# PDF extraction tools
sudo apt install libpoppler-cpp-dev default-jre default-jdk r-cran-rjava
sudo R CMD javareconf
R --vanilla << EOF
library(devtools)
install.packages("pdftools", repos = "https://cran.rstudio.com/")
install_github("ropensci/tabulizer")
q()
EOF
# TTF/OTF fonts usage
sudo apt install libfreetype6-dev
R --vanilla << EOF
install.packages("showtext", repos = "https://cran.rstudio.com/")
q()
EOF
# Cairo for graphic devices
sudo apt install libgtk2.0-dev libxt-dev libcairo2-dev
R --vanilla << EOF
install.packages("Cairo", repos = "https://cran.rstudio.com/")
q()
EOF
# Texlive for Latex/knitr
sudo apt -y install texlive
sudo apt -y install texlive-latex-recommended texlive-pictures texlive-latex-extra
@elibooklover

This comment has been minimized.

Copy link

elibooklover commented Feb 26, 2020

Thanks for the code! I have an issue to install "devtools" in Ubuntu 19.10. Any advice?

@luispuerto

This comment has been minimized.

Copy link
Owner Author

luispuerto commented Feb 27, 2020

@elibooklover Sorry, as far as I can remember I didn't have any. What kind of issue?

@moldach

This comment has been minimized.

Copy link

moldach commented Mar 23, 2020

Works great on POP!_OS too. Thanks

@ferreirafm

This comment has been minimized.

Copy link

ferreirafm commented Apr 1, 2020

I've got unmet dependencies as following:
r-base : Depends: r-base-core (>= 3.6.3-1bionic) but it is not going to be installed
Depends: r-recommended (= 3.6.3-1bionic) but it is not going to be installed
Recommends: r-base-html but it is not going to be installed
r-base-dev : Depends: r-base-core (>= 3.6.3-1bionic) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Any help is appreciated.

@luispuerto

This comment has been minimized.

Copy link
Owner Author

luispuerto commented Apr 2, 2020

@ferreirafm
What version are you using of Ubuntu?

@ferreirafm

This comment has been minimized.

Copy link

ferreirafm commented Apr 2, 2020

@luispuerto
root@krusty:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 19.10
Release: 19.10
Codename: eoan

@luispuerto

This comment has been minimized.

Copy link
Owner Author

luispuerto commented Apr 2, 2020

try again…

@ferreirafm

This comment has been minimized.

Copy link

ferreirafm commented Apr 2, 2020

just installing...
tks

@mberneti

This comment has been minimized.

Copy link

mberneti commented Apr 3, 2020

The following packages have unmet dependencies:
r-base : Depends: r-base-core (>= 3.6.3-1bionic) but it is not going to be installed
Depends: r-recommended (= 3.6.3-1bionic) but it is not going to be installed
Recommends: r-base-html but it is not going to be installed
r-base-dev : Depends: r-base-core (>= 3.6.3-1bionic) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

OS:Ubuntu 19.10

@mberneti

This comment has been minimized.

Copy link

mberneti commented Apr 3, 2020

It fixed after editing sources.list sudo gedit /etc/apt/sources.list file and removing added cran repository, I mean this line deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/;

@luispuerto

This comment has been minimized.

Copy link
Owner Author

luispuerto commented Apr 4, 2020

You perhaps have to change the last part of sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu eoan-cran35/' in relation of your ubuntu version. If you don't have the last version —eoan— will fail.

@mberneti

This comment has been minimized.

Copy link

mberneti commented Apr 4, 2020

My Ubuntu version is 19.10, What was I supposed to do?
How can I find a related repository link?

@luispuerto

This comment has been minimized.

Copy link
Owner Author

luispuerto commented Apr 4, 2020

@mberneti I just put it. Your version it eoan.

@mberneti

This comment has been minimized.

Copy link

mberneti commented Apr 4, 2020

@luispuerto oops ...
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.