Problem_1: (a)
x<-(5*4)
y<-((4*5))
z<-(x^y)-56
print(z)
## [1] 1.048576e+26
Problem_1: (b)
23-1*(8-12)
## [1] 27
Problem_1: (c)
56/8*(3+4)
## [1] 49
Problem_1: (d)
45-5*8+(8+9)
## [1] 22
Problem 2: (a)
a<- c(2,5,6,7)
Problem 2: (b)
b<- c(1,0,9,8)
Problem 2: (c)
c<- c(6,5,8,3)
Rowbind the vectors to form a 3X4 matrix.
mat<-c(a,b,c)
matrix(mat, nrow=3,ncol=4,byrow=TRUE)
## [,1] [,2] [,3] [,4]
## [1,] 2 5 6 7
## [2,] 1 0 9 8
## [3,] 6 5 8 3
Students<-matrix(mat, nrow=3,ncol=4,byrow=TRUE)
Change the column names to (Mon, Tue, Wed, Thu). Change the row names to (Present, Absent, On leave).
days<-c("Mon", "Tue", "Wed","Thu")
attandance<-c("Present"," Absent"," On leave")
colnames(Students)<-days
rownames(Students)<-attandance
print(Students)
## Mon Tue Wed Thu
## Present 2 5 6 7
## Absent 1 0 9 8
## On leave 6 5 8 3
Calculate the rowsums and the columnsums.
total_student_weekly<-rowSums(Students)
total_student_perday<-colSums(Students)
print(total_student_weekly)
## Present Absent On leave
## 20 18 22
print(total_student_perday)
## Mon Tue Wed Thu
## 9 10 23 18