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
#Create the vectors
a <- c(2, 5, 6, 7)
b <- c(1, 0, 9, 8)
c <- c(6, 5, 8, 3)
#Combine them into a matrix
matrix_data <- rbind(a, b, c)
# Rename the columns
colnames(matrix_data) <- c("Mon", "Tue", "Wed", "Thu")
# Rename the rows
rownames(matrix_data) <- c("Present", "Absent", "On leave")
# Print the matrix
print(matrix_data)
## Mon Tue Wed Thu
## Present 2 5 6 7
## Absent 1 0 9 8
## On leave 6 5 8 3
# Calculate row sums
row_sums <- rowSums(matrix_data)
print(row_sums)
## Present Absent On leave
## 20 18 22
# Calculate column sums
col_sums <- colSums(matrix_data)
print(col_sums)
## Mon Tue Wed Thu
## 9 10 23 18