# Rstudio

## Table of Contents

- Installing Rstudio
  - Linux (debian, ubuntu)
    - Installing R
    - Installing rstudio
  - Mac OSX and Windows
- Installing Git
  - Linux (debian, ubuntu)
  - Mac OSX and Windows
- Rstudio and git/github/gitlab
- Cheat Sheets

## Installing Rstudio

### Linux (debian, ubuntu)

We provide here only instructions for debian-based distributions. Feel free to contribute to this document to provide up-to-date information for other distributions (e.g.n redhat, fedora).

Today, the stable versions of the most common distributions provide recent enough versions of emacs and org-mode:

- Debian (stretch) ships with R 3.3.3-1, knitr 1.15.1, and ggplot 2.2.1
- Ubuntu (bionic 18.04) ships with R 3.4.4, and knitr 1.17, and ggplot 2.2.1
- Ubuntu (artful 17.04) ships with R 3.4.2, and knitr 1.15, and ggplot 2.2.1

If your distribution is older than this, well, it may be a good time for upgrading…

#### Installing R

Beforehand, you need to install the R language and convenient packages by running (as root):

    apt-get update ; sudo apt-get install r-base r-cran-knitr r-cran-ggplot2

Alternatively, if the installation of `r-cran-gplot2` or `r-cran-knitr` fails, you may want to install them locally (through the R packaging system) and manually by running the following commands in R (or Rstudio):

    install.packages("knitr")
    install.packages("ggplot2")

If you plan to export pdf documents with LaTeX, you probably also want to run (as root):

    apt-get update ; apt-get install texlive-base

#### Installing rstudio

Rstudio is unfortunately not packaged within debian so the easiest is to download the corresponding debian package on the Rstudio webpage and then to install it manually (depending on when you do this, you can obviously change the version number). Here is how to install it:

    cd /tmp/
    wget https://download1.rstudio.org/rstudio-xenial-1.1.453-amd64.deb
    sudo dpkg -i rstudio-xenial-1.1.453-amd64.deb
    sudo apt-get update ; sudo apt-get -f install # to fix possibly missing dependencies

### Mac OSX and Windows

> Some instructions on installing R and knitr must be missing. This should be tested and improved.

Download and install rstudio from the Rstudio webpage by choosing the right operating system.

Then open Rstudio and type the following commands in the console to install knitr and ggplot2:

    install.packages("knitr")
    install.packages("ggplot2")

## Installing Git

### Linux (debian, ubuntu)

We provide here only instructions for debian-based distributions. Feel free to contribute to this document to provide up-to-date information for other distributions (e.g.n redhat, fedora).

Run (as root):

    apt-get update ; apt-get install git

### Mac OSX and Windows

- Download and install Git from the Git website.
- Optional Git clients (should not be needed if you work within Rstudio):
  - SourceTree

  - GitHub Desktop

    > Apparently, this works with gitlab and https.

## Rstudio and git/github/gitlab

> We may want to redo a screencast in French for this

- This video on using git/githugb/gitlab from Rstudio (starting at time 9:09)

Alternatively, we can point to: http://www.geo.uzh.ch/microsite/reproducible_research/post/rr-rstudio-git/

- Part 1/item 2: Setup Git in RStudio
- Part 2 (to adapt to gitlab)
- Part 3

## Cheat Sheets

The Rstudio team has created a lot of good material and tutorials. You should definitively look at the Cheat sheets webpage. In particular you want to have look at the ones on:

- the Rstudio IDE,
- R Markdown,
- the R Markdown Reference guide,
- data visualization with ggplot2,
- data transformation with dplyr

In case it helps, here are some (sometimes outdated) French versions of these documents:

- L'IDE Rstudio
- Visualisation de données avec ggplot2
- Transformation de données avec dplyr
- Un court document sur R Markdown

Date: June, 2018

Author: Arnaud Legrand

Created: 2018-07-19 jeu. 14:26

Validate