DS Matrix QP
DS Matrix QP
Write a R program to :
(i) Create a vector ‘x’ having series of values from 1 to 15 and print it.
OUTPUT:
[1] "New vector using : operator-"
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[1] "New vector using seq() function-"
[1] "Specify step size:"
[1] 1.0 1.3 1.6 1.9 2.2 2.5 2.8
Output:
[1] "Original Vectors:"
[1] 10 20 30 25 9 26
[1] "Sort in ascending order:"
[1] 9 10 20 25 26 30
[1] "Sort in descending order:"
[1] 30 26 25 20 10 9
Output:
[,1] [,2] [,3] [,4] [,5]
[1,] NA NA NA NA NA
[2,] NA NA NA NA NA
[3,] NA NA NA NA NA
Output:
[1] "Original Matrix:"
[,1] [,2] [,3] [,4]
[1,] 1 2 3 4
[2,] 5 6 7 8
[3,] 9 10 11 12
[4,] 13 14 15 16
Output:
Output:
Output:
[1] "Matrix-1:"
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
[1] "Matrix-2:"
[,1] [,2] [,3]
[1,] 0 2 0
[2,] 1 3 2
[1] "Result of addition"
[,1] [,2] [,3]
[1,] 1 5 5
[2,] 3 7 8
[1] "Result of subtraction"
[,1] [,2] [,3]
[1,] 1 1 5
[2,] 1 1 4
[1] "Result of multiplication"
[,1] [,2] [,3]
[1,] 0 6 0
[2,] 2 12 12
[1] "Result of division:"
[,1] [,2] [,3]
[1,] Inf 1.500000 Inf
[2,] 2 1.333333 3