Start your Base R on your laptop or computer
Basically, R and Rstudio are the same software, however RStudio is an Integrated Development Environment (IDE) wherein you can run, edit
commands and see the results simaltanouesly. Therefore whatever commands that you run in Base R and RStudio will give the same results. Quickly
run some mathematical operations in Base R and move to RStudio
# is used for adding comments
# <- is considered as equal to sign in R
#Let us run command
print("Welcome to R!")
## print() is a function. it tells computer to do something
## “Welcome to R!” is an argument
the information function needs to run to give output
# Perform basic mathematical operation
#multiplying 12 by 6
#divide 12 by 6
# In Similar fashion you can do all the mathematical calculations.
Variable defination in R
# Variable defination in R # We are assigning value 3 to variable x and value 5 to variable y. Print the value of x and y
x <- 3
y <- 5
z <- x + y
n <- z
# assigning value to my_var
my_var <- 42
my_banana <- 6
my_apple <- 5
my_chikoo <- 5
my_pin <- 3
# adding fruits
my_basket <- my_banana + my_apple + my_chikoo + my_pin
avg_fruit <- (my_banana + my_apple + my_chikoo + my_pin)/4
Basic data types in R
## Numerics ## Character Text ## Boolean values
## Class of the data
> x <- 5.5
> y <- 5
> z<- 3 + 2i
> ## # The quotation marks indicate that the variable is of type character
> my_character <- " universe"
 " universe"
> class( my_character)
> my_character <- "1"
> my_logical <- TRUE
> my_logical <- FALSE
> ## What is the class of this variable?
> my_character42 <- "forty-two"