# 建立資料框 (Data Frame)
df <- data.frame(
Name = c("張青松", "王奕翔", "田新雨", "徐麗娜", "張志傑",
"趙穎睿", "王智強", "宋媛婷", "袁四方", "張建國"),
Statistic = c(68,85,74,88,63,78,90,80,58,63),
Math = c(85,91,74,100,82,84,78,100,51,70),
Japanese = c(84,63,61,49,89,51,59,53,79,91),
Management = c(89,76,80,71,78,60,72,73,91,85),
Accounting = c(86,66,69,66,80,60,66,70,85,82)
)
# 查看資料
df
## Name Statistic Math Japanese Management Accounting
## 1 張青松 68 85 84 89 86
## 2 王奕翔 85 91 63 76 66
## 3 田新雨 74 74 61 80 69
## 4 徐麗娜 88 100 49 71 66
## 5 張志傑 63 82 89 78 80
## 6 趙穎睿 78 84 51 60 60
## 7 王智強 90 78 59 72 66
## 8 宋媛婷 80 100 53 73 70
## 9 袁四方 58 51 79 91 85
## 10 張建國 63 70 91 85 82
# ------------------------
# 1. 各科莖葉圖 (Stem-and-leaf plot)
# ------------------------
stem(df$Statistic)
##
## The decimal point is 1 digit(s) to the right of the |
##
## 5 | 8
## 6 | 338
## 7 | 48
## 8 | 058
## 9 | 0
stem(df$Math)
##
## The decimal point is 1 digit(s) to the right of the |
##
## 5 | 1
## 6 |
## 7 | 048
## 8 | 245
## 9 | 1
## 10 | 00
stem(df$Japanese)
##
## The decimal point is 1 digit(s) to the right of the |
##
## 4 | 9
## 5 | 139
## 6 | 13
## 7 | 9
## 8 | 49
## 9 | 1
stem(df$Management)
##
## The decimal point is 1 digit(s) to the right of the |
##
## 6 | 0
## 7 | 12368
## 8 | 059
## 9 | 1
stem(df$Accounting)
##
## The decimal point is 1 digit(s) to the right of the |
##
## 6 | 06669
## 7 | 0
## 8 | 0256
# ------------------------
# 2. 基本統計量 (Mean / Max / Min)
# ------------------------
mean(df$Statistic)
## [1] 74.7
max(df$Statistic)
## [1] 90
min(df$Statistic)
## [1] 58
mean(df$Math)
## [1] 81.5
max(df$Math)
## [1] 100
min(df$Math)
## [1] 51
# ------------------------
# 3. 標準差 (Standard Deviation)
# ------------------------
sd(df$Statistic)
## [1] 11.32402
sd(df$Math)
## [1] 14.62304
sd(df$Japanese)
## [1] 16.25115
# ------------------------
# 4. 百分位數 (Quantiles)
# ------------------------
quantile(df$Statistic)
## 0% 25% 50% 75% 100%
## 58.00 64.25 76.00 83.75 90.00
quantile(df$Math)
## 0% 25% 50% 75% 100%
## 51.0 75.0 83.0 89.5 100.0
quantile(df$Japanese)
## 0% 25% 50% 75% 100%
## 49.00 54.50 62.00 82.75 91.00
quantile(df$Management)
## 0% 25% 50% 75% 100%
## 60.00 72.25 77.00 83.75 91.00
quantile(df$Accounting)
## 0% 25% 50% 75% 100%
## 60.0 66.0 69.5 81.5 86.0