Create the following vectors a, b, and c a) 2,5,6,7 b) 1,0,9,8 c) 6,5,8,3
Row bind the vectors to form a 3X4 matrix. Change the column names to (Mon, Tue, Wed, Thu). Change the row names to (Present, Absent, On leave). Calculate the row sums and the column sums.
Problem 1a
(5*4)^(4*5)-56
## [1] 1.048576e+26
Problem 1b
23-1*(8-12)
## [1] 27
Problem 1c
56/8*(3+4)
## [1] 49
Problem 1d
45-5*8+(8+9)
## [1] 22
Problem 2
a<-c(2,5,6,7)
b<-c(1,0,9,8)
c<-c(6,5,8,3)
d<-c(a,b,c)
mat<-matrix(d, byrow=TRUE,
nrow=3)
print(mat)
## [,1] [,2] [,3] [,4]
## [1,] 2 5 6 7
## [2,] 1 0 9 8
## [3,] 6 5 8 3
colnames(mat)<-c("Mon", "Tue", "Wed", "Thu")
rownames(mat)<-c('Present', 'Absent', 'On leave')
mat
## Mon Tue Wed Thu
## Present 2 5 6 7
## Absent 1 0 9 8
## On leave 6 5 8 3
row<-rowSums(mat)
row
## Present Absent On leave
## 20 18 22
col<-colSums(mat)
col
## Mon Tue Wed Thu
## 9 10 23 18