Installing and starting R
There is a Video that accompanies this chapter.
0.1 What’s it all about?
Put simply, R is one of the most favoured languages for statistics and data science, as well as a variety of closely linked fields (machine learning, for example). For a successful career in these fields, understanding at least a little R will set you up very well indeed.
Why is R so popular? Well, many reasons, but here are some
- R is free open-source software. It’s free to download, and runs on every major platform, and open-source, which means that you anyone can contribute and improve it.
- Because of this open source nature, you can do almost anything you want with R, and many people have written (free) libraries. If you want to do anything using data, such as forecast stock prices, draw fancy graphs, or collect cricket statistics, R has a package for you.
- R is relatively straightforward to do advanced things in. It’s not as powerful or as fast as C++ or Java, but within a couple of hours you can learn some very powerful techniques. R is nor just a programming language, it is an environment for doing statistics.
Many people, especially in data science or learning, use python instead of/as well as R. I think R is easier to start learning with, but both languages are used extensively throughout statistics and data science.
0.2 What is R Studio?
R Studio is the most used tool for using R. R is the environment itself, and R Studio is our way of operating R. (As an analogy, R is like the engine, whereas R Studio is the dashboard and controls of the car) Technically R Studio is an IDE (an Integrated Development Environment).
There are other tools for interfacing with R, but R Studio is so well known that it is default.
0.3 How to get started with R
0.3.1 Installation
You may be using a PC with R and R Studio already installed, in which case you can skip forward.
If R is not installed, you will need to install R first before you install R Studio.
Follow this link to the R Studio website where all the instructions are. To break this down a little:
- Install R
- Visit the CRAN website.
- Select your operating system
- Click on “base”
- Download and install the file in the normal way. The latest version (normally the first link at the top of the page) is fine.
- Install R Studio
- Visit the RStudio download page, and Click on the appropriate version for your Windows/Mac/Linux device. It will normally be well highlighted. You want the free, Desktop version of R Studio- do not attempt to give anybody money.
0.3.2 Checking the install
Start up RStudio (do not start R directly). On windows, hit the windows key and type “RStudio” in the search bar, and click on the app- R Studio should open and look similar to the image below.
In the box on the left, type “2+2” and hit return. Congratulations, you are now the world’s newest R user!