Professional Documents
Culture Documents
22MBA10001
Use vector arithmetic to multiply these vectors and call the result d. Select subsets of d to
(b) What are all of the elements of d which are less than 2000?
Solution:
a=seq(5,160,by=5)
b=seq(87,56,by=-1)
d=a*b
print(d)
(a) d[19:21]
(b) d[d<2000]
(c) length(d[d>6000])
Output:
following statistics of d:
(a) sum
(b) median
Solution code:
sum(d)
median(d)
sd(d)
Output:
Solution Code:
a=matrix(c(7,2,9,4,12,13),ncol = 3)
b=matrix(c(1,2,3,7,8,9,12,13,14,19,20,21),nrow = 3)
#matrix multiplication
c=a%*%b
Output: