Installing R and R Studio Basic functionality of R, variable, data types in R.
R programming language is a language and free software environment, available under GNU
license, supported by R Foundation for Statistical Computing. The language is most widely
known for its powerful statistical and data interpretation capabilities.
To use R language, you need the R environment to be installed on your machine, and an IDE
(Integrated development environment) to run the language (can also be run using CMD on
Windows or Terminal on Linux).
Installing R Studio on Window
To Install R Studio on windows we will follow the following steps.
Step 1: First, you need to set up an R environment in your local machine. You can download
the same from r-project.org.
Step 2: After downloading R for the Windows platform, install it by double-clicking it.
Step 3: Download R Studio from their official page. Note: It is free of cost (under AGPL
licensing).
R Programming Laboratory Manual
Department of CSE(AI), PEC 3
Step 4: After downloading, you will get a file named “RStudio-1.x.xxxx.exe” in your
Downloads folder.
Step 5: Double-click the installer, and install the software.
Step 6: Test the R Studio installation
Search for RStudio in the Window search bar on Taskbar.
Start the application.
Insert the following code in the console.
R Programming Laboratory Manual
Department of CSE(AI), PEC 4
Input : print('Hello world!')
Output : [1] "Hello world!"
Step 7: Your installation is successful.
Variables in R
R Programming Language is a dynamically typed language, i.e. the R Language Variables are
not declared with a data type rather they take the data type of the R-object assigned to them.
This feature is also shown in languages like Python and PHP.
Declaring and Initializing Variables in R Language
R supports three ways of variable assignment:
Using equal operator- operators use an arrow or an equal sign to assign values to
variables.
Using the leftward operator- data is copied from right to left.
Using the rightward operator- data is copied from left to right.
Using equal to operators
variable_name = value
using leftward operator
variable_name <- value
using rightward operator
value -> variable_name
Creating Variables in R
# R program to illustrate
# Initialization of variables
# using equal to operator
var1 = "hello"
print(var1)
# using leftward operator
var2 <- "hello"
print(var2)
# using rightward operator
"hello" -> var3
print(var3)
Output:
[1] "hello"
[1] "hello"
[1] "hello"