In this chapter we will guide you through the installation of R, RStudio and the packages you will need for this course.
IT IS NECESSARY TO FIRST INSTALL R AND SEQUENTIALLY RSTUDIO
You will need R installed on your computer. R stats (how it is also known) is a programming language and free software environment for statistical computing and graphics supported by the R Foundation for Statistical Computing.
The download links live at The Comprehensive R Archive
Network (aka CRAN). The most recent
version is 4.4.1
, but you can use >= 4.1.x
if you already have it
installed.
Download R-4.4.1 for Windows and run the executable file.
You will also need to install Rtools, which is a collection of tools necessary to build R packages in Windows.
Download R-4.4.1 for MacOX. You will have to choose between the arm64 or the x86-64 version.
Download the .pkg
file and install it as usual.
After this installation, you don’t need to open R base. Please proceed to install RStudio.
RStudio Desktop is an integrated development environment (IDE) for R. It includes a console, syntax-highlighting editor that supports direct code execution, as well as tools for plotting, history, debugging and workspace management.
RStudio is available for free download from Posit RStudio.
Download RStudio 2024.04 and run the executable file.
Download RStudio 2024.04 and install it as usual.
Open RStudio (not R !).
If you type sessionInfo()
at the console, it will show you the
packages you have with your installation.
You can install packages by the menu on the Packages tab
Try to install readxl
(to deal with MS Excel files). It will install
also some dependent packages.
You may also type in the console the packages or group of packages you’d like to install. Try to install these three packages with the console:
tidyverse
- a group of basic packages to deal with dataframes and graphics,RColorBrewer
- a package to use beautiful color palettes, anddevtools
- a package to deal with the development versions of packages
Type
install.packages(c(“tidyverse”,“devtools”,“RColorBrewer”))
Simply by calling them in the script;
library(tidyverse)
library(readxl)
When you restart R (Ctrl + Shift + F10
) you’ll need to load packages
again.
You can click here at the upper left icon, and select R Script
Or Ctrl + Shift + F
Or in the console, type file.edit("startup.R)
Start by typing the aim of that script, commented with a cardinal
(#)
You can comment/uncomment any line by selecting it and press
Ctrl + Shift + C
Save the script.
Step by step:
- click on “Session”;
- Click on “Set working directory”;
- Click on “Choose directory” and select the folder that contains the dataset.
Or you could just run
setwd("D:/MQAT/Methods-Quantitative-Analysis-Transportation") #for instance
Tools > Global Options > Appearence > Editor Theme > ...
Try to change to Cobalt, or check others you may like.
You can also change font, font-size, and even the panels layout.