Aclass <- c(11,16,19,18,20,23,19,21,24,29)
Bclass <- c(23,26,34,29,33,27,23,36,30,40)
plot(Aclass, Bclass)
abline(lm(Bclass~Aclass),col="skyblue")
cor(Aclass, Bclass)
## [1] 0.6991015
An education researcher is interested in how variables, such as GRE (Graduate Record Exam scores), GPA (grade point average) and prestige of the undergraduate institution (Rank), influence admission into graduate school (Admit).
dta <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")
str(dta)
## 'data.frame': 400 obs. of 4 variables:
## $ admit: int 0 1 1 1 0 1 1 0 1 0 ...
## $ gre : int 380 660 800 640 520 760 560 400 540 700 ...
## $ gpa : num 3.61 3.67 4 3.19 2.93 3 2.98 3.08 3.39 3.92 ...
## $ rank : int 3 3 1 4 4 2 1 2 3 2 ...
tail(dta,10)
## admit gre gpa rank
## 391 1 800 3.05 2
## 392 1 660 3.88 2
## 393 1 600 3.38 3
## 394 1 620 3.75 2
## 395 1 460 3.99 3
## 396 0 620 4.00 2
## 397 0 560 3.04 3
## 398 0 460 2.63 2
## 399 0 700 3.65 2
## 400 0 600 3.89 3
plot(dta$gre,dta$gpa)
library(lattice)
xyplot(gre ~ gpa | factor(rank), data = dta, type = c("g","p","r"), layout = c(4, 1))
head(dta,7) str(dta)
library(lattice) xyplot(gre ~ gpa | factor(rank), data = dta, type = c(“g”,“p”,“r”), layout = c(4, 1))
plot(dta\(gre,dta\)gpa)
```