Hello everyone,

Welcome to the Discrete Choice Analysis course, my name is Siddhartha Gulhare and I am the instructor for this course. We will be using an open source package Apollo in R for discrete choice analysis. I will keep publishing short documents here to help you with the R programming. These documents are inspired from numerous data science blogs and the content will be mainly derived from two sources - Apollo Manual and R for Data Science book.

Install R and RStudio

R is a programming language while RStudio is an Integrated Development Environment (IDE) which provides a user friendly interface for R. The section 1.1 in the book ‘Statistical Inference via Data Science: A ModernDive into R and the tidyverse’ explains the difference more intuitively.

We need to first install R, RStudio and the relevant packages.

Once you install them, you will notice that RStudio has multiple panes -

  1. Console
  2. Environment and History
  3. File, Plots, Packages, Help and Viewer

We can start a new script by clicking on File %>% New File %>% R Script. Please read this operator %>% as then, we will visit this operator %>% again later. The script would be the new pane in top left.

Multiple panes in RStudio

If you want you can rearrange the layout of panel by clicking on Tools %>% Global Options.. %>% Panel Layout. You can also change the appearance of RStudio by clicking Tools %>% Global Options.. %>% Appearance and then choose between the Editor themes.

Install packages

The package is a fundamental unit of reusable code. They enhance the capability of R by either improving base R function or by adding new functions. There are around 17,000 packages in R. We can install them using the command install.packages("insert package name here") in the console. We will mainly discuss two packages here Apollo and tidyverse. We can install more packages later whenever required.

Apollo

Apollo is a free, fully customisable, easy to use package available in R and does not rely on commercial softwares as host. It is developed by Dr. Stephane Hess and his team at University of Leeds. For more details, please read chapter 1 of Apollo manual. The manual can be downloaded from here.

Copy this command in console and press enter to install Apollo package: install.packages("apollo")

Tidyverse

Tidyverse is a collection of packages designed for data science. It can be used for data import, transformation, exploration, visualization, etc. A good source to learn tidyverse is the book - R for Data Science

Copy this command in console and press enter to install tidyverse package: install.packages("tidyverse")