This is the R command using for our final research about
RESEARCH ON WEIGHT, HEIGHT, AND TOTAL SCORE OF FAST 2021 FRESHMAN
For this part, we will discussing through each feature:
1/ Overview our data
2/ Weight
3/ Height
4/ Total_score
In order to finish our project, we need to install some library
#install.packages("readxl")
#install.packages("ggplot2")
#install.packages("lubridate")
#install.packages("qqplotr")
library(readxl) #for read excel
library(ggplot2) # for plot
library(grid)
library(qqplotr)
##
## Attaching package: 'qqplotr'
## The following objects are masked from 'package:ggplot2':
##
## stat_qq_line, StatQqLine
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
That’s all, so now, let’s go:
First, loading data from excel file to R:
setwd("C:/Work_places/SXTK/Final_Report/Descriptive_statistics")
data <- read_excel("Data_Statistic.xlsx")
dim(data)
## [1] 156 5
head(data)
## # A tibble: 6 × 5
## Class Birthdays Height Weight Total_score
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 21ECE 9102003 169 54 24.8
## 2 21ECE 15072003 182 88 26.6
## 3 21ECE 14082003 160 55.2 25.2
## 4 21ECE 7092003 162 62.3 23.8
## 5 21ECE 20032003 163 47 23.7
## 6 21ECE 2062003 178 61 22.1
–> contain 156 observation ( FAST 2021 freshman) with 5 variables( Class, Height, Weight, Total_score)
print("Summary weight of FAST 2021 freshman ")
## [1] "Summary weight of FAST 2021 freshman "
summary(data$Weight)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 40.00 51.00 60.00 60.07 68.00 90.00
summary_all <- tapply(data$Weight, data$Class, summary)
print(summary_all)
## $`21ECE`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 46.50 53.50 63.75 63.80 75.00 88.00
##
## $`21ES`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 50.00 55.00 65.00 64.65 73.00 85.00
##
## $`21PFIEV`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 40.0 50.0 59.0 57.6 64.0 90.0
The highest weight of FAST 2021 freshman is in 21PFIEV which 90kg
The lowest weight in 3 classes belongs to 21PFIEV: 40kg
The median weight of FAST 2021 freshman is 60kg
#histogram of Weight
ggplot(data, aes(x = Weight, fill = Class)) +
geom_histogram(binwidth = 5, position = "stack", color = "black", alpha = 0.5) +
geom_density(aes(y = after_stat(count * 5)), fill = "transparent", color = "red") +
labs(title = "Histogram of Weight ( FAST 2021 freshman)",
x = "Weight(kg)",
y = "Number") +
scale_fill_brewer(palette = "Set3") # Lựa chọn màu sắc cho từng lớp
# 2 histogram của 2 lớp cho weight
ggplot(data, aes(x = Weight, fill = Class)) +
geom_histogram(binwidth = 5, position = "stack", color = "black", alpha = 0.7) +
geom_density(aes(y = after_stat(count * 5)), fill = "transparent", color = "red") +
labs(title = "Histogram of Weight ( FAST 2021 freshman)",
x = "Weight(kg)",
y = "Number") +
scale_fill_brewer(palette = "Set3") + # Lựa chọn màu sắc cho từng lớp
facet_grid(Class ~ ., scales = "free_y") # Hiển thị theo cột "Class"
#boxplot for weight
ggplot(data, aes(x = Weight, y = Class)) +
geom_boxplot(width = 0.3, fill = "slateblue", color = "black", position = position_dodge(width = 0.7)) +
geom_point(position = position_dodge(width = 0.7), color = "red", size = 2) +
labs(title = "Boxplot of Weight ( FAST 2021 freshman)",
x = "Weight(kg)",
y = "Class") +
theme_minimal()
There is one outlier in 21PFIEV class.
ggplot(data, aes(sample = Weight, fill = Class)) +
stat_qq_band() +
stat_qq_point(size = 2) +
stat_qq_line() +
xlab("Theoretical Quantiles") + ylab("Sample Quantiles") +
ggtitle("Normal Q-Q plot of heights") +
theme(plot.title = element_text(hjust = 0.5)) +
facet_grid(Class ~ ., scales = "free_y") # Hiển thị theo cột "Class"
The QQ-plot charts also give the conclusion that the weight variable of 3 classes may follow the normal distribution since almost points in 3 charts are in the line area.
summary(data$Height)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 150.0 164.4 170.0 168.9 174.0 183.3
ggplot(data, aes(x = Height, fill = Class)) +
geom_histogram(binwidth = 5, position = "stack", color = "black", alpha = 0.7) +
geom_density(aes(y = after_stat(count * 5)), fill = "transparent", color = "red") +
labs(title = "Histogram of Height ( FAST 2021 freshman)",
x = "Height(cm)",
y = "Number") +
scale_fill_brewer(palette = "Set3") # Lựa chọn màu sắc cho từng lớp
# 2 histo của 2 lớp cho height
ggplot(data, aes(x = Height, fill = Class)) +
geom_histogram(binwidth = 5, position = "stack", color = "black", alpha = 0.7) +
geom_density(aes(y = after_stat(count * 5)), fill = "transparent", color = "red") +
labs(title = "Histogram of Height ( FAST 2021 freshman)",
x = "Height(cm)",
y = "Number") +
scale_fill_brewer(palette = "Set3") + # Lựa chọn màu sắc cho từng lớp
facet_grid(Class ~ ., scales = "free_y") # Hiển thị theo cột "Class"
From this we can clearly conclude that the sample is approximately normally distributed.
Number of students heighting about 160 to 180 cm is the highest.
#boxplot for height
ggplot(data, aes(x = Height, y = Class)) +
geom_boxplot(width = 0.3, fill = "slateblue", color = "black", position = position_dodge(width = 0.7)) +
geom_point(position = position_dodge(width = 0.7), color = "red", size = 2) +
labs(title = "Boxplot of Height ( FAST 2021 freshman)",
x = "Height(cm)",
y = "Class") +
theme_minimal()
21PFIEV exhibits a more uniform distribution compared to the 21ES and 21ECE classes.
None of the three classes have any outliers
ggplot(data, aes(x = Height, y = Weight, color = Class)) +
geom_point(alpha = 0.7) +
geom_point() +
geom_smooth(method="lm")+
labs(title = "Distribution of Height and Weight ( FAST 2021 freshman)",
x = "Height(cm)",
y = "Weight(kg)") +
scale_color_manual(values = c("red","blue","green"))
## `geom_smooth()` using formula = 'y ~ x'
print("Summary Total score of FAST 2021 freshman ")
## [1] "Summary Total score of FAST 2021 freshman "
summary(data$Total_score)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 17.00 22.74 23.90 23.62 24.70 27.00
summary_all <- tapply(data$Total_score, data$Class, summary)
print(summary_all)
## $`21ECE`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 20.75 23.07 23.93 23.93 24.84 26.55
##
## $`21ES`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 20.60 23.40 24.50 24.19 25.25 27.00
##
## $`21PFIEV`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 17.00 22.52 23.60 23.35 24.57 26.70
The highest score of FAST 2021 freshman is in 21ES which 27
The lowest score in 3 classes belongs to 21PFIEV: 17 score
The median score of FAST 2021 freshman is 23.9
#boxplot for score
ggplot(data, aes(x = Total_score, y = Class)) +
geom_boxplot(width = 0.3, fill = "slateblue", color = "black", position = position_dodge(width = 0.7)) +
geom_point(position = position_dodge(width = 0.7), color = "red", size = 2) +
labs(title = "Boxplot of Score ( FAST 2021 Freshman)",
x = "Score",
y = "Class") +
theme_minimal()
The total entering scores of students of 21ES are higher than the other.
In 21PFIEV, there are 2 outliers, and three outliers in 21ES.
ggplot(data, aes(x = Total_score, fill = Class)) +
geom_histogram(binwidth = 1, position = "stack", color = "black", alpha = 0.7) +
geom_density(aes(y = after_stat(count * 1)), fill = "transparent", color = "red") +
labs(title = "Histogram of Score ( FAST 2021 Freshman) ",
x = "Score",
y = "Frequency") +
xlim(c(15, 30)) +
scale_fill_brewer(palette = "Set3") # Lựa chọn màu sắc cho từng lớp
## Warning: Removed 6 rows containing missing values (`geom_bar()`).
ggplot(data, aes(x = Total_score, fill = Class)) +
geom_histogram(binwidth = 1, position = "stack", color = "black", alpha = 0.7) +
geom_density(aes(y = after_stat(count * 1)), fill = "transparent", color = "red") +
labs(title = "Histogram of Score ( FAST 2021 Freshman)",
x = "Score",
y = "Frequency") +
xlim(c(15, 30)) +
scale_fill_brewer(palette = "Set3") + # Lựa chọn màu sắc cho từng lớp
facet_grid(Class ~ ., scales = "free_y") # Hiển thị theo cột "Class"
## Warning: Removed 6 rows containing missing values (`geom_bar()`).
#### Comment
The histogram of total score for 21ECE students can be approximately considered normally distributed (symmetric unimodal)
While the histogram of total score for 21ES and 21 PFIEV students have a negatively skewed shapes
ggplot(data, aes(sample = Total_score, fill = Class)) +
stat_qq_band() +
stat_qq_point(size = 2) +
stat_qq_line() +
xlab("Theoretical Quantiles") + ylab("Sample Quantiles") +
ggtitle("Normal Q-Q plot of heights") +
theme(plot.title = element_text(hjust = 0.5)) +
facet_grid(Class ~ ., scales = "free_y") # Hiển thị theo cột "Class"
The QQ-plot charts also give the conclusion that the Score variable of 3 classes may follow the normal distribution since almost points in 3 charts are in the line area.
Comment :
The histogram of weight for FAST 2021 freshman can be approximately considered normally distributed (symmetric unimodal)
Most 3 class have Weight ranging from 50 to 70.
21ES class can see considered bimodal share.