Ex 19. 1,000 명의 학생들의 SAT와 GPS 성적을 수록하고 있는 Data Set 1이 의 사이트에 수록되어 있다.
a. SAT 성적의 범위와 표본 표준편차를 구하라.
b. GPS 성적의 범위와 표본 표준편차를 구하라.
[Solution]
install.packages("readxl")
library(readxl)
dataset1 <- read_excel("data1.xls")
str(dataset1)
# Data Set 1
sat <- dataset1[[1]]
gpa <- dataset1[[2]]
# list of Data Set
head(sat)
head(gpa)
# a.
range_SAT <- max(sat) - min(sat)
range_SAT
sd(sat)
# b.
range_GPA <- max(gpa) - min(gpa)
range_GPA
sd(gpa)
> str(dataset1)
> str(dataset1)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 1000 obs. of 2 variables:
$ SAT Score : num 1300 1520 1580 1430 1610 1230 1520 1320 1240 1480 ...
$ College GPA: num 3.66 2.92 2.66 2.27 2.35 2.02 2.94 1.76 2.35 3.16 ...
>
> # list of Data Set
> head(sat)
[1] 1300 1520 1580 1430 1610 1230
> head(gpa)
[1] 3.66 2.92 2.66 2.27 2.35 2.02
dataset1 <- read_excel("data1.xls")
str(dataset1)
# Population Data Set
sat <- dataset1[[1]]; head(sat)
# a.
range_SAT <- max(sat) - min(sat) ; range_SAT
sd(sat)
# Sample Data Set : First 25 Observations.
sat <- dataset1[[1]][1:25]; sat
# b.
range_SAT <- max(sat) - min(sat) ; range_SAT
sd(sat)
# Sample Data Set : First 25 Observations.
sat <- dataset1[[1]][26:50]; sat
# c.
range_SAT <- max(sat) - min(sat) ; range_SAT
sd(sat)
> # Population Data Set
> sat <- dataset1[[1]]; head(sat)
[1] 1300 1520 1580 1430 1610 1230
>
> # a.
> range_SAT <- max(sat) - min(sat) ; range_SAT
[1] 1350
> sd(sat)
[1] 212.5455
> # Sample Data Set : First 25 Observations.
> sat <- dataset1[[1]][1:25]; sat
[1] 1300 1520 1580 1430 1610 1230 1520 1320 1240 1480 1780 1870 1140 1580 1520 1510 1490 1760 1430 1630 1960 1330
[23] 1520 1430 1390
>
> # b.
> range_SAT <- max(sat) - min(sat) ; range_SAT
[1] 820
> sd(sat)
[1] 197.5373
> # Sample Data Set : Next 25 Observations.
> sat <- dataset1[[1]][26:50]; sat
[1] 1700 1320 1540 1510 1120 1690 1870 1450 1430 1850 1510 1510 1700 1330 1820 1360 1820 1670 1690 1330 1520 1180
[23] 1700 1430 1330
>
> # c.
> range_SAT <- max(sat) - min(sat) ; range_SAT
[1] 750
> sd(sat)
[1] 209.6052
Ex 21. Data Set 1의 GPA성적을 이용하여 다음을 구하라.
[Solution]
dataset1 <- read_excel("data1.xls")
str(dataset1)
# Population Data Set
gpa <- dataset1[[2]]; head(gpa)
# a.
range_GPA <- max(gpa) - min(gpa) ; range_GPA
sd(gpa)
# Sample Data Set : First 25 Observations.
gpa <- dataset1[[2]][1:25]; gpa
# b.
range_GPA <- max(gpa) - min(gpa) ; range_GPA
sd(gpa)
# Sample Data Set : Next 25 Observations.
gpa <- dataset1[[2]][26:50]; gpa
# c.
range_GPA <- max(gpa) - min(gpa) ; range_GPA
sd(gpa)
> # Population Data Set
> gpa <- dataset1[[2]]; head(gpa)
[1] 3.66 2.92 2.66 2.27 2.35 2.02
>
> # a.
> range_GPA <- max(gpa) - min(gpa) ; range_GPA
[1] 4
> sd(gpa)
[1] 0.7407454