Skip to content

Instantly share code, notes, and snippets.

@mjfrigaard
Last active August 30, 2018 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjfrigaard/9c340b0945dbf4bed59da368d5875e6c to your computer and use it in GitHub Desktop.
Save mjfrigaard/9c340b0945dbf4bed59da368d5875e6c to your computer and use it in GitHub Desktop.
Setting up RStudio on Ubuntu (UCSF PHDI)

Installing packages in RStudio on Ubuntu

This document covers installing packages on RStudio server (Ubuntu).

System Specs

Currently using:

Release 16.04.5 LTS (Xenial Xerus) 64-bit
Kernel Linux 4.4.0-134-generic x86_64
MATE 1.12.1

And

RStudio Version 1.1.456 
Mozilla/5.0 

Follow the directions on this post.

Run In Terminal

These get run in the terminal (password required):

sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev
sudo apt-get install libxml2-dev
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libfreetype6-dev

Install R on Ubuntu 16.04

  1. Add R repository First, we’ve got to add a line to our /etc/apt/sources.list file. This can be accomplished with the following. Note the “xenial” in the line, indicating Ubuntu 16.04. If you have a different version, just change that.
sudo echo "deb http://cran.rstudio.com/bin/linux/ubuntu xenial/" | sudo tee -a /etc/apt/sources.list

This returned the following:

deb http://cran.rstudio.com/bin/linux/ubuntu xenial/

Add R to Ubuntu Keyring

gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -

I did not do the following steps:

Install R-Base Most Linux users should be familiar with the old… sudo apt-get update sudo apt-get install r-base r-base-dev

Install R packages

Run the following code, need ~ 10 min to install all these packages.

This gets run in the RStudio source file.

    # options for loading form CRAN
    options("repos" = c(CRAN = "http://cran.rstudio.com/"))
    # packages to install
    install.packages(c("fs",
                       "mdsr",
                       "data.table", 
                       "knitr", 
                       "RCurl", 
                       "XML", 
                       "ggmap", 
                       "raster", 
                       "openair", 
                       "rasterVis", 
                       "viridisLite", 
                       "sf", 
                       "geomnet", 
                       "ggrepel", 
                       "showtext", 
                       "geosphere", 
                       "kableExtra", 
                       "ggsn", 
                       "tidyverse", 
                       "magrittr", 
                       "readxl",
                       "haven",
                       "jsonlite",
                       "httr",
                       "rvest",
                       "DBI",
                       "readODS",   # Import ODS (OpenDocument Spreadsheet", into R as a data
                       "rmatio",    # Reading and writing Matlab MAT files from R
                       "readxl",   # reading excel sheets into R
                       "lubridate",
                       "hms",
                       "blob",
                       "reshape",   # flexibly reshape data with melt and cast
                       "reshape2",  # again
                       "magrittr",
                       "glue",
                       "GGally",
                       "gganimate",
                       "ggExtra",
                       "ggfittext",
                       "ggformula",
                       "ggridges",
                       "ggnetwork",
                       "ggvis",
                       "ggrepel",
                       "ggtern",
                       "ggthemes",
                       "ggmap",     # ggmap for maps
                       "gcookbook", # package contains data sets used in r graphics cookbook"
                       "lattice",  # lattice package
                       "timevis",   # create rich and fully interactive timeline visualizations
                       "tidymodels",
                       "ISLR",      # introduction to statistical learning package
                       "e1071",     # misc functions from dept of stats, prob theory group
                       "memisc",    # tools for managing survey data presentation of analysis
                       "Hmisc",     # contains many functions useful for data analysis,
                       "LOGIT",     # functions, data and code for PGLR
                       "caret",     # model data
                       "broom",     # data frames for messy output of built-in functions in R
                       "faraway",   # linear models in R
                       "AppliedPredictiveModeling", # applied predicitive modeling book
                       "regtools",  # regression tools
                       "skimr",     # tiny histograms
                       "janitor",   # crosstabs and nice tables
                       "tableone",    # create tables
                       "urltools",  # A toolkit for all URL-handling needs
                       "csvy",      # import and export csv data with a yaml metadata header
                       "feather",   # access a feather store like a data frame
                       "fst",       # read and write data frames at high speed.
                       "datapasta", # easy copy and paste
                       "gutenbergr",  # download and process public domain works in project
                       "tidytext",    # text manipulation/modeling (tidy approach",
                       "scales",      # commas
                       "stringi",     # string manipulation
                       "xtable",      # coerce data to latex and html tables
                       "rmdformats",  # formatting Rmd files
                       "rmdHelpers",  # helpers
                       "furniture",   # crosstabulations of variables
                       "styler",      # style code easily
                       "nycflights13", # the infamous flights data
                       "Lahman",      # data tables from the 'Sean Lahman Baseball Database'
                       "Ecdat",       # data sets for econometrics
                       "HistData",    # data sets from the history of statistics and data viz
                       "fivethirtyeight", # data sets from http://fivethirtyeight.com/
                       "DBI", # provides connection to DBMS with a “front-end” and a “back-end”
                       "RMySQL", # MySQL driver for DBI
                       "RMariaDB", # MariaDB driver for DBI
                       "RPostgreSQL")) # PostgreSQL driver for DBI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment