This is the assignment file
Let’s do the following calculations
(5*4)^(4*5)-56
## [1] 1.048576e+26
23-1*(8-12)
## [1] 27
56/8*(3+4)
## [1] 49
45-5*8+(8+9)
## [1] 22
Now let’s do some vector calculation First let’s create some vectors
a <- c(2, 5, 6, 7)
a
## [1] 2 5 6 7
class(a)
## [1] "numeric"
b <- c(1, 0, 9, 8)
b
## [1] 1 0 9 8
class(b)
## [1] "numeric"
c <- c(6, 5, 8, 3)
c
## [1] 6 5 8 3
class(c)
## [1] "numeric"
Let’s see the matrix in 3*4 form
mat<-matrix(c(a,b,c), byrow=TRUE, nrow=3)
mat
## [,1] [,2] [,3] [,4]
## [1,] 2 5 6 7
## [2,] 1 0 9 8
## [3,] 6 5 8 3
Now let’s rowbind them
rbind(a,b,c)
## [,1] [,2] [,3] [,4]
## a 2 5 6 7
## b 1 0 9 8
## c 6 5 8 3
Let’s name the coloums and rows
colnames(mat)<-c("Mun", "Tue", "Wed", "Thu")
rownames(mat)<-c('Present', 'Absent', 'On leave')
mat
## Mun Tue Wed Thu
## Present 2 5 6 7
## Absent 1 0 9 8
## On leave 6 5 8 3
Let’s do rowsums and columnsums
row<-rowSums(mat)
row
## Present Absent On leave
## 20 18 22
col<-colSums(mat)
col
## Mun Tue Wed Thu
## 9 10 23 18