#Vectors
a<-c(2,5,6,7)
b<-c(1,0,9,8)
c<-c(6,5,8,3)
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
#Column name
colnames(mat)<-c("Mon", "Tue", "Wed", "Thu")
#Row name
rownames(mat)<-c("Present", "Absent", "On leave")
mat
## Mon Tue Wed Thu
## Present 2 5 6 7
## Absent 1 0 9 8
## On leave 6 5 8 3
#Row sums
row<-rowSums(mat)
row
## Present Absent On leave
## 20 18 22
#Column sums
col<-colSums(mat)
col
## Mon Tue Wed Thu
## 9 10 23 18
#Row bind
rbind(mat,col)
## Mon Tue Wed Thu
## Present 2 5 6 7
## Absent 1 0 9 8
## On leave 6 5 8 3
## col 9 10 23 18
#Data set
data<-mtcars
#Scatter pot
plot(data$mpg, data$disp,
xlab = "Mpr",
ylab = "Disp",
main = "Mpr vs Disp",
col = "red")
#Boxplot
boxplot(data$mpg, data$gear,
xlab = "Gear",
ylab = "Mpr",
main = "Mpr with Gear",
col = "blue")
#Histogram
hist(data$disp,
main = "Disp",
col = "grey", breaks = 10)