##以後習慣將常用的指令都先loading
library(lattice)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyr)
library(magrittr)
## 
## Attaching package: 'magrittr'
## The following object is masked from 'package:tidyr':
## 
##     extract
dta<- read.table("C:/tmp/beautyCourseEval.txt", h = T)
##看一下讀檔狀況
head(dta)
##   eval     beauty sex age minority tenure courseID
## 1  4.3  0.2015666   1  36        1      0        3
## 2  4.5 -0.8260813   0  59        0      1        0
## 3  3.7 -0.6603327   0  51        0      1        4
## 4  4.3 -0.7663125   1  40        0      1        2
## 5  4.4  1.4214450   1  31        0      0        0
## 6  4.2  0.5002196   0  62        0      1        0
##上週學過的回歸與合併圖指令
lattice::xyplot(eval ~ beauty | courseID, type = c("p", "g", "r"), data =dta , auto.key = list(columns = 2), xlab = "eval", ylab = "beauty")

##splom()應該是畫散點矩陣圖,但不是這次需要的方式
splom(~ dta[,c("eval", "minority", "tenure", "beauty")] ,groups = courseID, 
      data=dta,
      pch='.', 
      axis.text.cex=0.3,
      par.settings=standard.theme(color=FALSE))