The following data visualisation is done one IQ_levels dataset.In this we will compare the worldwide IQ levels and we rank the countries.
data=read.csv("C:/Users/moola/OneDrive/Desktop/IQ_levels.csv")
summary(data)
## rank country IQ education_expenditure
## Min. : 1.00 Length:108 Min. : 51.00 Min. : 1.0
## 1st Qu.: 27.75 Class :character 1st Qu.: 78.75 1st Qu.: 81.5
## Median : 54.50 Mode :character Median : 88.00 Median : 336.0
## Mean : 54.50 Mean : 85.97 Mean : 903.1
## 3rd Qu.: 81.25 3rd Qu.: 97.00 3rd Qu.:1360.0
## Max. :108.00 Max. :106.00 Max. :5436.0
## NA's :5
## avg_income avg_temp
## Min. : 316 Min. : 0.40
## 1st Qu.: 2263 1st Qu.:17.25
## Median : 7533 Median :25.85
## Mean : 17175 Mean :23.86
## 3rd Qu.: 30040 3rd Qu.:31.27
## Max. :108349 Max. :36.50
## NA's :2
str(data)
## 'data.frame': 108 obs. of 6 variables:
## $ rank : int 1 2 3 4 5 6 7 8 9 10 ...
## $ country : chr "Hong Kong\xa0" "Japan" "Singapore" "Taiwan\xa0" ...
## $ IQ : int 106 106 106 106 104 103 101 101 100 100 ...
## $ education_expenditure: int 1283 1340 1428 NA 183 1024 2386 2725 2052 NA ...
## $ avg_income : int 35304 40964 41100 NA 4654 22805 45337 42706 40207 NA ...
## $ avg_temp : num 26.2 19.2 31.5 26.9 19.1 18.2 14.4 8.2 7.4 15.3 ...
plot(data)
library(ggplot2)
ggplot(data=data)+labs(title="World wide IQ_Levels")
ggplot(data=data,aes(x=rank,y=avg_income,col=IQ))+labs(title="Worldwide IQ_levels")
ggplot(data = data, aes(x =rank, y =avg_income, col =IQ)) +
geom_point() +
labs(title = "rank vs avg_income", x = "rank", y = "ang_income")
## Warning: Removed 2 rows containing missing values (`geom_point()`).
ggplot(data = data, aes(x =rank , y = avg_income, size =IQ)) +
geom_point() +
labs(title = "rank vs avg_income", x = "rank", y = "avg_income")
## Warning: Removed 2 rows containing missing values (`geom_point()`).
ggplot(data = data, aes(x =rank , y = avg_income, col = factor(IQ), shape = factor(avg_temp))) +geom_point() +
labs(title = "rank vs avg_income", x = "rank", y = "avg_income")
## Warning: The shape palette can deal with a maximum of 6 discrete values because
## more than 6 becomes difficult to discriminate; you have 91. Consider
## specifying shapes manually if you must have them.
## Warning: Removed 101 rows containing missing values (`geom_point()`).
data$rank<-factor(data$rank)
ggplot(data, aes(x = factor(rank), y =avg_income )) +
geom_point()
## Warning: Removed 2 rows containing missing values (`geom_point()`).
data$IQ=as.integer(data$IQ)
ggplot(data = data, aes(x =IQ )) +
geom_histogram(binwidth = 5,color="black", fill="lightblue") +
labs(title = "Histogram of IQ", x = "IQ.", y = "Country")
ggplot(data = data, aes(x=as.factor(IQ), fill=IQ)) +
geom_bar(stat="count")
rank.type = table(data$rank)
rank.avg_income = table(data$rank, data$avg_income)
barplot(rank.type, main="worldwide rank", xlab="rank",ylab="avgerage income",names.arg=names(rank.type),col=c("blue","green","yellow"),legend = rownames(rank.avg_income))
rank = table(data$rank )
data.labels = names(rank )
share = round(rank/sum(rank)*100)
data.labels = paste(data.labels, share)
data.labels = paste(data.labels,"%",sep="")
pie(rank,labels = data.labels,clockwise=TRUE, col=heat.colors(length(data.labels)), main="worldwide rank of all countries")
bx <- ggplot(data = data, aes(x = factor(IQ), y = rank)) +
geom_boxplot(fill = "blue") +
ggtitle("Worldwide IQ_levels") +
ylab("rank") +
xlab("IQ")
bx