#Creating the vectors
a <- c(2,5,6,7)
b <- c(1,0,9,8)
c <- c(6,5,8,3)
#Row-binding the vectors to form a 3*4 matrix
matrixdata <- rbind(a,b,c)
#Changing the column names
colnames(matrixdata) <- c("Mon", "Tue", "Wed", "Thu")
#Changing the row names
rownames(matrixdata) <- c("Present", "Absent", "On Leave")
#Calculating the row and columns sums & Printing
row_sums <- rowSums(matrixdata)
column_sums <- colSums(matrixdata)
print(matrixdata)
## Mon Tue Wed Thu
## Present 2 5 6 7
## Absent 1 0 9 8
## On Leave 6 5 8 3
print(row_sums)
## Present Absent On Leave
## 20 18 22
print(column_sums)
## Mon Tue Wed Thu
## 9 10 23 18