Math.
Biz June 2024
How to install R and RStudio
A.1 How to Download and Install R
R is maintained by an international team of developers who make the language available through
the web page of The Comprehensive R Archive Network (Link 1). The top of the web page
provides three links for downloading R. Follow the link that describes your operating system:
Windows, Mac, or Linux.
Link1: [Link]
Link 2: [Link]
1. Windows
To install R on Windows, click the “Download R for Windows” link. Then click the “base” link.
Next, click the first link at the top of the new page. This link should say something like “Download
R-4.4.0 for Windows,” except the 4.4.0 will be replaced by the most current version of R (at the
time of compiling this document, R-4.4.0 is the latest version). The link downloads an installer
program, which installs the most up-to-date version of R for Windows. Run this program and step
through the installation wizard that appears. The wizard will install R into your program files
folders and place a shortcut in your Start menu. Note that you’ll need to have all of the
appropriate administration privileges to install new software on your machine.
2. Mac
To install R on a Mac, click the “Download R for Mac” link. Next, click on the R-4.4.0 package link
(or the package link for the most current release of R). An installer will download to guide you
through the installation process, which is very easy. The installer lets you customize your
installation, but the defaults will be suitable for most users. I’ve never found a reason to change
them. If your computer requires a password before installing new programs, you’ll need it here.
Also, depending on the Mac OS version, you might require to download the appropriate package
file. Se instructions on [Link]
Rstudio:
RStudio is an application like Microsoft Word—except that instead of helping you write in English,
RStudio helps you write in R. I use RStudio throughout the book because it makes using R much
easier. Also, the RStudio interface looks the same for Windows, Mac OS, and Linux.
1
[Link] June 2024
You can download RStudio for free (use Link 2). Just click the “Download RStudio” button against
your OS (Windows or Mac) and follow the simple instructions. Once you’ve installed RStudio, you
can open it like any other program on your computer—usually by clicking an icon on your
desktop.
Your RStudio console would look like the picture below.
Packages
Files
Once you have RStudio up and running, let us set up a working directory for R.
1. Create a folder “R_files” (please give any name that you want) in Documents folder of
your PC.
2. Go to RStudio. Click on Files located on the bottom right panel (see the picture above to
locate “Files”). Once you click on Files, a list of folders on your PC will appear in the
window.
3. Click on “Documents” folder. Then check the file that you have created “R_files”. Now
you have set your working directory to "R_files”.
2
[Link] June 2024
Now let us download some important packages to RStudio. For this:
1. Click on the “Packages” button on the bottom right panel. This will display all the packages
that are installed currently.
2. Click on Install button (see figure below)
3. A window will pop up (see figure below)
4. Type the name of the package that you want to install. Let us start with “rmarkdown”.
Once you type rmarkdown into the Packages field, click install. Make sure you check the
Install dependencies check box. Once you click install, you will see several lines of code
appearing in console. Once the installation is successful you will get a screen similar to
the one shown below.
5. Now let us go ahead and install a few more packages in the same manner. Here is a link
to a YouTube video that demonstrates how to install packages. [Link]
wTcDqJWSzA?si=OVxYfJAsSs899Kh1
3
[Link] June 2024
6. The packages that you need to install are (apart from rmarkdown):
1) Base
2) car
3) carData
4) corrplot
5) datasets
6) dplyr
7) dbplyr
8) dtplyr
9) fma
10) forecast
11) foreign
12) fpp2
13) ggplot2
14) haven
15) knitr
16) modelr
17) readr
18) readxl
19) shiny
20) stats
21) tibble
22) tidyverse
23) xlsx
You are now all set for the class. See you soon.
In case of any doubts, please reach out to [Link]@[Link]