Problem 1 (a)
print ((5*4)^(4*5)-56)
## [1] 1.048576e+26
Problem 1 (b)
print (23-1*(8-12))
## [1] 27
Problem 1 (c)
print (56/8*(3+4))
## [1] 49
Problem 1 (d)
print (45-5*8+(8+9))
## [1] 22
Problem 2
Forming vectors
print (a <- c(2,5,6,7))
## [1] 2 5 6 7
print (b <- c(1,0,9,8))
## [1] 1 0 9 8
print (c <- c(6,5,8,3))
## [1] 6 5 8 3
Rowbinding the vectors to form a 3X4 matrix
print (matrix <- rbind (a,b,c))
## [,1] [,2] [,3] [,4]
## a 2 5 6 7
## b 1 0 9 8
## c 6 5 8 3
Naming columns and rows
print (colnames(matrix) <- c("Mon", "Tue", "Wed", "Thu"))
## [1] "Mon" "Tue" "Wed" "Thu"
print (rownames(matrix) <- c("Present", "Absent", "On leave"))
## [1] "Present" "Absent" "On leave"
Calculating the rowsums and the columnsums
print (row_sums <- rowSums (matrix))
## Present Absent On leave
## 20 18 22
print (col_sums <- colSums (matrix))
## Mon Tue Wed Thu
## 9 10 23 18