Professional Documents
Culture Documents
MBA - P02 - Aditya Nitnaware
MBA - P02 - Aditya Nitnaware
Specialization: MBA- BA
Name: Aditya Nitnaware
UID: 2023-0909-0001-0005
Practical No. 02
Title: Implementation of various operations on matrix and data-frame using R.
Objective: To provide the knowledge and develop the skills to apply various operations on data
structures in R.
Answer
# Creating a matrix
A = matrix(c(10,24,-10,15,15,25,24,18,40),nrow = 3,ncol = 3)
B = matrix(c(45,30,10,35,-25,40,24,20,50),nrow = 3,ncol = 3)
A+B
A-B
A*B
A[2,]
#d) Extract the first and third element of second row of matrix A.
A[c(1,3),2]
B[B==B[2,2]]<-50
B
Answer
DF1
DF2
#a) Join the both data frames to create a single data frame.
DF3[3,]
#c) Extract the data which display employee names with their salary.
DF3[,c(1,5)]
mean(DF3$Salary)