Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install R on Ubuntu 16.04
# add CRAN to apt sources
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
printf '\n#CRAN mirror\ndeb https://cran.dcc.uchile.cl/bin/linux/ubuntu xenial/\n' | sudo tee -a /etc/apt/sources.list
# install R
sudo apt-get update
sudo apt-get install libxml2-dev libssl-dev libcurl4-gnutls-dev gfortran libopenblas-dev
sudo apt-get install r-base r-base-dev
# install common packages
R --vanilla << EOF
install.packages(c("tidyverse","data.table","dtplyr","devtools","roxygen2"), repos = "https://cran.rstudio.com/")
q()
EOF
# install Rstudio
wget https://s3.amazonaws.com/rstudio-dailybuilds/rstudio-xenial-1.1.379-amd64.deb
sudo apt-get install gdebi
sudo gdebi rstudio-xenial-1.1.379-amd64.deb
# datasets for lectures
R --vanilla << EOF
install.packages("HistData", repos = "https://cran.rstudio.com/")
q()
EOF
# Econometrics
R --vanilla << EOF
install.packages(c("plm","np","bbmle","micEcon"), repos = "https://cran.rstudio.com/")
q()
EOF
# Structural equation modelling (SEM)
R --vanilla << EOF
install.packages(c("lavaan","semPlot","semTools","nonnest2"), repos = "https://cran.rstudio.com/")
q()
EOF
# Exploratory data analysis (EDA)
R --vanilla << EOF
library(devtools)
devtools::install_github("ropenscilabs/skimr")
q()
EOF
# Export to HTML/Excel
sudo apt-get install default-jre default-jdk
sudo apt-get install r-cran-rjava
sudo R CMD javareconf
R --vanilla << EOF
install.packages(c("htmlTable","openxlsx","XLConnect"), 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 pip install markdown rpy2==2.7.8 pelican==3.6.3
# PDF extraction tools
sudo apt-get install libpoppler-cpp-dev
R --vanilla << EOF
library(devtools)
install.packages("pdftools", repos = "https://cran.rstudio.com/")
install_github("ropensci/tabulizer")
q()
EOF
# TTF/OTF fonts using
sudo apt-get install libfreetype6-dev
R --vanilla << EOF
install.packages("showtext", repos = "https://cran.rstudio.com/")
q()
EOF
# Cairo for graphic devices
sudo apt-get install build-essential libgtk2.0-dev libcairo2-dev libxt-dev
R --vanilla << EOF
install.packages("Cairo", repos = "https://cran.rstudio.com/")
q()
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment