讀取資料
dta <- read.table("C:/Users/X510/Desktop/2020-04-13-Homework-4-Trellis/timetrial.dat.txt", header = T)[-35,]
dta$progress <- dta$Trial1 - dta$Trial5 #進步
dta$average <- (dta$Trial1 + dta$Trial2 + dta$Trial3 + dta$Trial4 + dta$Trial5)/5 #五次測驗平均
head(dta)## Sex Age Trial1 Trial2 Trial3 Trial4 Trial5 progress average
## 1 M 31 0.051 0.023 0.106 0.076 0.013 0.038 0.0538
## 2 M 30 0.074 0.006 0.003 0.020 0.022 0.052 0.0250
## 3 M 30 0.051 0.094 0.084 0.176 0.103 -0.052 0.1016
## 4 M 27 0.182 0.166 -0.073 -0.044 0.029 0.153 0.0520
## 5 M 30 0.077 0.001 0.000 -0.027 -0.200 0.277 -0.0298
## 6 M 28 0.103 0.065 0.063 0.059 0.059 0.044 0.0698
男性反應的時間集中,女性分散的較廣
從圖上看起來,年齡越小的男性,似乎反應得較為準確;年齡越大的女性,反應得較為準確(但是點點分散得很開,因此也不能從直線做判斷)
25歲以下,反應的時間較為分散,尤其是女生;25歲以上則顯得較為集中
## 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
## 2.0 7.0 8.0 10.0 11.0 13.0 25.8 31.0 37.8 40.0 52.0
Y_O <- with(dta, cut(Age, ordered=T, breaks=c(0, 25, 60), labels=c("Young", "Old"))) #分為年齡小、年齡大兩組
dta.1 <- cbind(dta, Y_O)
xyplot(average ~ Age | Y_O, groups=Sex, data=dta.1, type=c('p', 'g'))無論反應是「提早、剛好、太慢」的三組,年齡大多集中在十幾歲的族群。但是二十幾歲族群的資料較少,所以較難以了解二十幾歲的人反應如何
## 0% 10% 20% 30% 40% 50% 60% 70%
## -0.32720 -0.11602 -0.03172 -0.00698 0.02428 0.04760 0.06564 0.09098
## 80% 90% 100%
## 0.12132 0.16760 0.41520
EMA <- with(dta, cut(average, ordered=T, breaks=c(-1, -.006, .07, 0.5), labels=c("Early", "Median", "Late"))) #將反應時間拆成三組
dta.2 <- cbind(dta.1, EMA)
bwplot(Age ~ Sex | EMA, data=dta,xlab="average")