students<-read.delim("C:\\Users\\ahmad\\Downloads\\Datasets\\students.txt",stringsAsFactors=F)

Exercise 6

Creating the table:

tab <- matrix(c(66, 53, 28, 28, 17,11,3), ncol=1, byrow=TRUE)
colnames(tab) <- c("Frequency")
rownames(tab) <- c("Industry","Master student","Acadamic Faculty","Researcher","Doctoral Student","Undergraduate Student","Non-profit")
tab <- as.table(tab)

Creating a data frame:

ex6 <- data.frame(Frequency = c(66, 53, 28, 28, 17,11,3), Background
= c("Industry","Master student","Acadamic Faculty","Researcher","Doctoral Student","Undergraduate Student","Non-profit"))

Creating a barchart:

barplot(Frequency ~ Background, ex6, col = 1:7)
legend("top", ex6$Background, fill = 1:7)

Creating a barchart using ggplot2

library(ggplot2)
ggplot(ex6, aes(x = Background, y = Frequency, fill = Background)) + geom_col()

EX7

library(mosaic)
## Registered S3 method overwritten by 'mosaic':
##   method                           from   
##   fortify.SpatialPolygonsDataFrame ggplot2
## 
## The 'mosaic' package masks several functions from core packages in order to add 
## additional features.  The original behavior of these functions should not be affected by this.
## 
## Attaching package: 'mosaic'
## The following objects are masked from 'package:dplyr':
## 
##     count, do, tally
## The following object is masked from 'package:Matrix':
## 
##     mean
## The following object is masked from 'package:ggplot2':
## 
##     stat
## The following objects are masked from 'package:stats':
## 
##     binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
##     quantile, sd, t.test, var
## The following objects are masked from 'package:base':
## 
##     max, mean, min, prod, range, sample, sum
tally(~Blood_group, data=students)
## Blood_group
##  0  A AB  B 
## 31 35  5 11
prop(~Blood_group, success = "0", data = students)
##    prop_0 
## 0.3780488
prop(~Blood_group, success = "A", data = students)
##    prop_A 
## 0.4268293
prop(~Blood_group, success = "AB", data = students)
##    prop_AB 
## 0.06097561
prop(~Blood_group, success = "B", data = students)
##    prop_B 
## 0.1341463
 blood_pie <- c(31,35,5,11)
pie(blood_pie, labels = c("Blood group 0", "A", "AB", "B"))

 blood_pieRF <- c(0.3780488,0.4268293 ,0.06097561,0.1341463 )
pie(blood_pieRF, labels = c("Blood group 0", "A", "AB", "B"))

EX 8

bargraph(~Points_exam, data=students)

# ex 9

 histogram(~Size_cm, data = students)

# EX 10

 tally(~ Grade, data=students)
## Grade
##  1  2  3  4  5 
## 14 12 27  8 21
prop(~Grade, success = "1", data = students)
##    prop_1 
## 0.1707317
prop(~Grade, success = "2", data = students)
##    prop_2 
## 0.1463415
prop(~Grade, success = "3", data = students)
##    prop_3 
## 0.3292683
prop(~Grade, success = "4", data = students)
##     prop_4 
## 0.09756098
prop(~Grade, success = "5", data = students)
##    prop_5 
## 0.2560976

using ab freq pie chart

blood_pie <- c(14, 12, 27,  8, 21 )
pie(blood_pie, labels = c("Grade 1", "2", "3", "4","5"))

using ab freq pie chart

blood_pie <- c(0.1707317, 0.1463415 , 0.3292683 ,  0.09756098 
, 0.2560976  )
pie(blood_pie, labels = c("Grade 1", "2", "3", "4","5"))

bar chart

bargraph(~Grade, data=students)

# Ex 11

histogram(~Weight_kg, data = students)