#1 enter the data in the software
student<-c("ZIM", "DRC", "BOTS", "ANG", "SA", "DRC", "MOZ", "ZIM", "SA", "MAL", "ZIM", "ZIM", "MOZ", "ANG", "BOTS", "ZIM", "MOZ", "MAL", "SA", "ZIM", "DRC", "MOZ", "DRC", "MAL", "MAL", "NAM", "MOZ", "SA", "MAL", "BOTS", "LES", "MAL", "DRC", "MAL", "BOTS", "SA", "SA", "LES", "MAL", "LES", "LES", "SA", "ZIM", "ZIM", "SA", "MOZ", "DRC", "ANG" )
#2 PRESENT THE DATA ON A FREQUENCY DISTRIBUTION TABLE
freq_table<-table(student)
freq_table
## student
## ANG BOTS DRC LES MAL MOZ NAM SA ZIM
## 3 4 6 4 8 6 1 8 8
#3Calculate the relative frequencies and percentages for each catagory
rel_freq<-prop.table(freq_table)
rel_freq
## student
## ANG BOTS DRC LES MAL MOZ NAM
## 0.06250000 0.08333333 0.12500000 0.08333333 0.16666667 0.12500000 0.02083333
## SA ZIM
## 0.16666667 0.16666667
percentages<-rel_freq*100
percentages
## student
## ANG BOTS DRC LES MAL MOZ NAM SA
## 6.250000 8.333333 12.500000 8.333333 16.666667 12.500000 2.083333 16.666667
## ZIM
## 16.666667
#combine into a data frame
distribution<-data.frame(
country=names(freq_table),
frequency=as.vector(freq_table),
relative_freq=round(as.vector(rel_freq),4),
percentages=round(as.vector(percentages),2)
)
distribution
## country frequency relative_freq percentages
## 1 ANG 3 0.0625 6.25
## 2 BOTS 4 0.0833 8.33
## 3 DRC 6 0.1250 12.50
## 4 LES 4 0.0833 8.33
## 5 MAL 8 0.1667 16.67
## 6 MOZ 6 0.1250 12.50
## 7 NAM 1 0.0208 2.08
## 8 SA 8 0.1667 16.67
## 9 ZIM 8 0.1667 16.67
pie(freq_table, main="STUDENT DISTRIBUTION BY COUNTRY",
col=rainbow(length(freq_table)))

#bar chat
barplot(freq_table, main="STUDENT DISTRIBUTION BY COUNTRY",
col="blue",
ylab = "NUMBER OF STUDENTS")

expected<-rep(length(student)/length(freq_table),
length(freq_table))
chisq.test(freq_table,
p=rep(1/length(freq_table),
length(freq_table)))
##
## Chi-squared test for given probabilities
##
## data: freq_table
## X-squared = 9.375, df = 8, p-value = 0.3117
#5 use chi squared test to determine the observed distribution of students by your country significantly differs from a hypothesized or expected uniform distribution