Introduction To R And RStudio

What is R?

 
R is a programming language developed by Robert Gentlemen & Ross Ihaka in 1993. It is used for statistical computing. R is a software environment which allows statistical analysis, graphical representation, and reporting.
 
R includes various libraries which are made for data science. It is freely available for various operating systems like Linux, Windows, and Mac. 
 
It is an interpreted computer language. 
 
R is widely used in academics as it is a language to do statistics. Besides, it is used by healthcare, consulting, government, and other sectors too.
 

How to download and install R?

 
Go here.
 
Introduction To R And R Studio
 
Click on "Download R for Linux/Windows/Mac" on the basis of the operating system you are using. I am using Windows, hence I clicked on "Download R for Windows".
 
Introduction To R And R Studio
 
 On the next screen, click on "Download R 3.6.1 for Windows" (or a newer version that appears).
 
Introduction To R And R Studio
 
Click on the downloaded executable file and install by not changing the default installation options. Just keep pressing "Next" in the installation wizard till it is done.
 
R will be successfully installed. 
 
Now, in order to use R, we will install RStudio. 
 

What is RStudio? 

 
RStudio is an Integrated Development Environment (IDE) for R. It is free and open source. It is a GUI based tool which allows you to write and execute R scripts comfortably.
 
RStudio has various windows which help you in debugging and running complex programs. It also has many customization options. 
 

How to install RStudio? 

 
Go here.
 
Download RStudio for Windows.
 
Introduction To R And R Studio
 
Download the installer as per your operating system and follow the default installation options.
 
With this, you have both R and RStudio successfully installed. 
 
Double click on RStudio icon and open it.
 
Introduction To R And R Studio
 
As you can see in the screenshot above, RStudio opens up with 3 windows when you open it for the first time.
 

Writing the first program in R

 
Most of the people who are familiar with programming are familiar with the "Hello World" program. Let us write a simple program in R to display "Hello World".
  1. Open RStudio 
  2. Click on File -> New File -> R Script OR Alternatively you can press "Ctrl + Shift + N" on your keyboard
  3. A new window will open up
You can write your R program in this window.
  1. myMsg <- "Hello, World!"  
  2. print ( myMsg)  
 Now, select the above program (Ctrl + A) and then press the "Run" button (OR press Ctrl + Enter)
 
This will execute the program and you would be able to see the variable myMsg defined in the Environment window and see the text "Hello World" printed in the Console window.
 
Introduction To R And R Studio
 
This was a simple explanation of what R and RStudio are and how to write a simple R program. Please do practice on your own to learn it better. Feel free to write back to me in the comments section. 
 
Now as you are ready with R and RStudio, you must know about the data types and variables in R.
 
Read next in this series: Variables and Data types in R and begin your programming journey with R.
 
Happy Learning! 


Similar Articles