Q1

The math attainment page has a dataset and a script of R code chunks. Generate a markdown file from the script to push the output in HTML for posting to course Moodle site.

input data

#first R session using math attainment data set

# read in a plain text file with variable names and assign a name to it
dta <- read.table("C:/Users/Ching-Fang Wu/Documents/dataM/math_attainment.txt", header = T)

checking data

# structure of data
str(dta)
## 'data.frame':    39 obs. of  3 variables:
##  $ math2: int  28 56 51 13 39 41 30 13 17 32 ...
##  $ math1: int  18 22 44 8 20 12 16 5 9 18 ...
##  $ cc   : num  328 406 387 167 328 ...

math attainment的資料結構為data.frame,稱作資料框架。

#查看資料
View(dta) 

用View()看資料框架,它是由直排的行(column)所組成,每一行代表一個變數。

# first 6 rows
head(dta)
##   math2 math1     cc
## 1    28    18 328.20
## 2    56    22 406.03
## 3    51    44 386.94
## 4    13     8 166.91
## 5    39    20 328.20
## 6    41    12 328.20

descriptive statistics

# variable mean
colMeans(dta) #colMeans顧名思義是行平均
##     math2     math1        cc 
##  28.76923  15.35897 188.83667
#試試看rowMeans(列平均)
rowMeans(dta)
##  [1] 124.73333 161.34333 160.64667  62.63667 129.06667 127.06667  68.76000
##  [8]  37.64667  41.40000 127.20667 126.73333  89.12000  79.45333  81.12000
## [15]  84.03667  56.08333  54.41667  90.51333  78.70333  24.24000  54.02667
## [22]  63.46333  37.75333  53.94000  85.14333  51.60667  64.75000  59.71667
## [29]  47.15667  57.60667  63.22333  79.47667  62.71667  74.38000  74.14333
## [36]  84.47667  81.89333  72.87000  55.27333
# variable sd
#apply sd to dta
apply(dta, 2, sd) #2是column;1是row
##     math2     math1        cc 
## 10.720029  7.744224 84.842513
# correlation matrix 相關係數矩陣
cor(dta) 
##           math2     math1        cc
## math2 1.0000000 0.7443604 0.6570098
## math1 0.7443604 1.0000000 0.5956771
## cc    0.6570098 0.5956771 1.0000000

plot data

# specify square plot region
par(pty="s") 
#pty是指plot type繪圖類型或繪圖區域,"s"或"m"
# scatter plot of math2 by math1
plot(math2 ~ math1, data=dta, xlim=c(0, 60), ylim=c(0, 60),xlab="Math score at Year 1", ylab="Math score at Year 2") 


# add grid lines
grid() #增加輔助線

plot()是用來畫散布圖,表達方式是plot(Y~X),或plot(x=X軸的值,y=Y軸的值)。其他設定:xlim=x軸範圍,ylim=y軸範圍,main=“圖片名稱”,xlab=“X軸名稱”,ylab=“Y軸名稱”

regression analysis

# regress math2 by math1
dta.lm <- lm(math2 ~ math1, data=dta)
# show results
summary(dta.lm)
## 
## Call:
## lm(formula = math2 ~ math1, data = dta)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -10.430  -5.521  -0.369   4.253  20.388 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   12.944      2.607   4.965 1.57e-05 ***
## math1          1.030      0.152   6.780 5.57e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.255 on 37 degrees of freedom
## Multiple R-squared:  0.5541, Adjusted R-squared:  0.542 
## F-statistic: 45.97 on 1 and 37 DF,  p-value: 5.571e-08

截距項=12.94,斜率為1.03

# show anova table
anova(dta.lm)
## Analysis of Variance Table
## 
## Response: math2
##           Df Sum Sq Mean Sq F value    Pr(>F)    
## math1      1 2419.6 2419.59  45.973 5.571e-08 ***
## Residuals 37 1947.3   52.63                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# 畫迴歸的趨勢線
plot(math2 ~ math1, data=dta, xlim=c(0, 60), ylim=c(0, 60),xlab="Math score at Year 1", ylab="Math score at Year 2")+abline(dta.lm,lty=2)+title("Mathematics Attainment")

## integer(0)
#lty是線的類型(0=blank, 1=solid (default), 2=dashed, 3=dotted, 4=dotdash, 5=longdash, 6=twodash) 
#lwd是線的粗細
#title("Mathematics Attainment")是add plot title

整理:plot()畫散布圖後,可以在畫布上用其他函式增添其他訊息,如points()=畫上點;legend()=作上標記;abline()=畫上線

diagnostics

# specify maximum plot region
par(pty="m")
#
plot(scale(resid(dta.lm)) ~ fitted(dta.lm), 
     ylim=c(-3.5, 3.5), type="n",
     xlab="Fitted values", ylab="Standardized residuals")

#Add Text to a Plot
text(fitted(dta.lm), scale(resid(dta.lm)), labels=rownames(dta), cex=0.5)  

#加上輔助線
grid()

# add a horizontal red dash line
abline(h=0, lty=2, col="red")

normality check

#
qqnorm(scale(resid(dta.lm)))

qqline(scale(resid(dta.lm)))

grid()

Q2

The notation, women{datasets}, indicates that a data object by the name women is in the datasets package. This package is preloaded when R is invoked. Explain the difference between c(women) and c(as.matrix(women)) using the women{datasets}.

women
##    height weight
## 1      58    115
## 2      59    117
## 3      60    120
## 4      61    123
## 5      62    126
## 6      63    129
## 7      64    132
## 8      65    135
## 9      66    139
## 10     67    142
## 11     68    146
## 12     69    150
## 13     70    154
## 14     71    159
## 15     72    164

women資料集裡面有15位女性的身高、體重的數據

str(women)
## 'data.frame':    15 obs. of  2 variables:
##  $ height: num  58 59 60 61 62 63 64 65 66 67 ...
##  $ weight: num  115 117 120 123 126 129 132 135 139 142 ...

women的資料結構(Structure)是data.frame

x<-c(women)
str(x)
## List of 2
##  $ height: num [1:15] 58 59 60 61 62 63 64 65 66 67 ...
##  $ weight: num [1:15] 115 117 120 123 126 129 132 135 139 142 ...

c(women)把data frame變成list

y<-as.matrix(women)

women原為data.frame,透過as.matrix()可轉換為matrix資料結構

str(y)
##  num [1:15, 1:2] 58 59 60 61 62 63 64 65 66 67 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ : NULL
##   ..$ : chr [1:2] "height" "weight"
is.matrix(y)
## [1] TRUE
z<-c(as.matrix(women)) 
is.vector(z)
## [1] TRUE

結論: women的資料結構為data.frame,c(women)的資料結構為list。

as.matrix(women)的資料結構為matrix,c(as.matrix(women))的資料結構為vector。

疑問1:c()會讓資料結構”升級”?

比較差異:Matrices和Data frames

Matrices和Data frames都有row、column,但兩者究竟有何不同?

matrix(letters, 2, 13) #matrix會有[,]標示出列行位置,但沒有變數名稱。
##      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
## [1,] "a"  "c"  "e"  "g"  "i"  "k"  "m"  "o"  "q"  "s"   "u"   "w"   "y"  
## [2,] "b"  "d"  "f"  "h"  "j"  "l"  "n"  "p"  "r"  "t"   "v"   "x"   "z"
data.frame(letters, 2, 13) #data.frame沒有[,]標示出列行,資料是由column vector組成,而且有變數名稱。
##    letters X2 X13
## 1        a  2  13
## 2        b  2  13
## 3        c  2  13
## 4        d  2  13
## 5        e  2  13
## 6        f  2  13
## 7        g  2  13
## 8        h  2  13
## 9        i  2  13
## 10       j  2  13
## 11       k  2  13
## 12       l  2  13
## 13       m  2  13
## 14       n  2  13
## 15       o  2  13
## 16       p  2  13
## 17       q  2  13
## 18       r  2  13
## 19       s  2  13
## 20       t  2  13
## 21       u  2  13
## 22       v  2  13
## 23       w  2  13
## 24       x  2  13
## 25       y  2  13
## 26       z  2  13

Q3

Use help to examine the coding scheme for the mother’s race variable in the birthwt{MASS} dataset.

The MASS comes with the base R installation but is not automatically loaded when R is invoked.

How many black mothers are there in this data frame?

What does the following R command do? > c(“White”, “Black”, “Other”)[birthwt$race]

#用data這個指令,從套件MASS中載入birthwt這個資料集
data(birthwt,package = "MASS")
head(birthwt)
##    low age lwt race smoke ptl ht ui ftv  bwt
## 85   0  19 182    2     0   0  0  1   0 2523
## 86   0  33 155    3     0   0  0  0   3 2551
## 87   0  20 105    1     1   0  0  0   1 2557
## 88   0  21 108    1     1   0  0  1   2 2594
## 89   0  18 107    1     1   0  0  1   0 2600
## 91   0  21 124    3     0   0  0  0   0 2622
str(birthwt)
## 'data.frame':    189 obs. of  10 variables:
##  $ low  : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ age  : int  19 33 20 21 18 21 22 17 29 26 ...
##  $ lwt  : int  182 155 105 108 107 124 118 103 123 113 ...
##  $ race : int  2 3 1 1 1 3 1 3 1 1 ...
##  $ smoke: int  0 0 1 1 1 0 0 0 1 1 ...
##  $ ptl  : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ ht   : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ ui   : int  1 0 0 1 1 0 0 0 0 0 ...
##  $ ftv  : int  0 3 1 2 0 0 1 1 1 0 ...
##  $ bwt  : int  2523 2551 2557 2594 2600 2622 2637 2637 2663 2665 ...
# 從dataframe中取出race這個vector
birthwt$race
##   [1] 2 3 1 1 1 3 1 3 1 1 3 3 3 3 1 1 2 1 3 1 3 1 1 3 3 1 1 1 2 2 2 1 2 1 2 1 1
##  [38] 1 1 1 2 1 2 1 1 1 1 3 1 3 1 3 1 1 3 3 3 3 3 3 3 3 3 1 3 3 3 3 1 2 1 3 3 2
##  [75] 1 2 1 1 2 1 1 1 3 3 3 3 3 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 3 1 3 2 1 1 1 2 1
## [112] 3 1 1 1 3 1 3 1 3 1 3 1 1 1 1 1 1 1 1 3 1 2 3 3 3 3 2 3 1 1 1 3 3 1 1 2 1
## [149] 3 3 3 1 1 1 1 3 2 1 2 3 1 3 3 3 2 1 3 3 1 1 2 2 2 3 3 1 1 1 1 2 3 3 1 3 1
## [186] 3 3 2 1

race是數值(num),不知道各自代表甚麼人種。

#
c("White", "Black", "Other")[birthwt$race]
##   [1] "Black" "Other" "White" "White" "White" "Other" "White" "Other" "White"
##  [10] "White" "Other" "Other" "Other" "Other" "White" "White" "Black" "White"
##  [19] "Other" "White" "Other" "White" "White" "Other" "Other" "White" "White"
##  [28] "White" "Black" "Black" "Black" "White" "Black" "White" "Black" "White"
##  [37] "White" "White" "White" "White" "Black" "White" "Black" "White" "White"
##  [46] "White" "White" "Other" "White" "Other" "White" "Other" "White" "White"
##  [55] "Other" "Other" "Other" "Other" "Other" "Other" "Other" "Other" "Other"
##  [64] "White" "Other" "Other" "Other" "Other" "White" "Black" "White" "Other"
##  [73] "Other" "Black" "White" "Black" "White" "White" "Black" "White" "White"
##  [82] "White" "Other" "Other" "Other" "Other" "Other" "White" "White" "White"
##  [91] "White" "Other" "White" "White" "White" "White" "White" "White" "White"
## [100] "White" "White" "White" "Other" "White" "Other" "Black" "White" "White"
## [109] "White" "Black" "White" "Other" "White" "White" "White" "Other" "White"
## [118] "Other" "White" "Other" "White" "Other" "White" "White" "White" "White"
## [127] "White" "White" "White" "White" "Other" "White" "Black" "Other" "Other"
## [136] "Other" "Other" "Black" "Other" "White" "White" "White" "Other" "Other"
## [145] "White" "White" "Black" "White" "Other" "Other" "Other" "White" "White"
## [154] "White" "White" "Other" "Black" "White" "Black" "Other" "White" "Other"
## [163] "Other" "Other" "Black" "White" "Other" "Other" "White" "White" "Black"
## [172] "Black" "Black" "Other" "Other" "White" "White" "White" "White" "Black"
## [181] "Other" "Other" "White" "Other" "White" "Other" "Other" "Black" "White"

c(“White”, “Black”,“Other”)是將”White”編碼為1,“Black”=2,“Other”=3。

#table()函數可知道向量中每個值出現幾次
table(birthwt$race)
## 
##  1  2  3 
## 96 26 67

2=Black,有26個。

Q4

Regarding UCBAdmissions{datasets} data object, what does the output > UCBAdmissions[,1,] > UCBAdmissions[,1,1] > UCBAdmissions[1,1,]

of each of the above R statements mean, respectively?

data(UCBAdmissions,package = "datasets")
UCBAdmissions
## , , Dept = A
## 
##           Gender
## Admit      Male Female
##   Admitted  512     89
##   Rejected  313     19
## 
## , , Dept = B
## 
##           Gender
## Admit      Male Female
##   Admitted  353     17
##   Rejected  207      8
## 
## , , Dept = C
## 
##           Gender
## Admit      Male Female
##   Admitted  120    202
##   Rejected  205    391
## 
## , , Dept = D
## 
##           Gender
## Admit      Male Female
##   Admitted  138    131
##   Rejected  279    244
## 
## , , Dept = E
## 
##           Gender
## Admit      Male Female
##   Admitted   53     94
##   Rejected  138    299
## 
## , , Dept = F
## 
##           Gender
## Admit      Male Female
##   Admitted   22     24
##   Rejected  351    317

看起來很像多重列聯表,呈現在不同科系A~F,“錄取、不錄取”vs”男性、女性”之間的人數。

str(UCBAdmissions)
##  'table' num [1:2, 1:2, 1:6] 512 313 89 19 353 207 17 8 120 205 ...
##  - attr(*, "dimnames")=List of 3
##   ..$ Admit : chr [1:2] "Admitted" "Rejected"
##   ..$ Gender: chr [1:2] "Male" "Female"
##   ..$ Dept  : chr [1:6] "A" "B" "C" "D" ...

UCBAdmissions的資料結構是table,有3個list,依序是Admit、Gender、Dept。

UCBAdmissions[Admit,Gender,Dept]

#各系所錄取之男女生人數
UCBAdmissions[1,,] #1是Admitted、2是Rejected
##         Dept
## Gender     A   B   C   D   E   F
##   Male   512 353 120 138  53  22
##   Female  89  17 202 131  94  24
#各系所男生錄取與不錄取人數
UCBAdmissions[,1,] #1是男性、2是女性
##           Dept
## Admit        A   B   C   D   E   F
##   Admitted 512 353 120 138  53  22
##   Rejected 313 207 205 279 138 351
#Dept = A,男性,錄取與不錄取的人數
UCBAdmissions[,1,1] #[, 1=男性, 1=Dept=A]
## Admitted Rejected 
##      512      313
#各系所男性錄取人數
UCBAdmissions[1,1,]#[1=錄取,1=男性,]
##   A   B   C   D   E   F 
## 512 353 120 138  53  22

Q5

What happens when the following command is entered? > help(ls(“package:MASS”)[92])

Use the observation to find out how many items there are in the package MASS.

#install.packages("MASS")
library(MASS)
data(package = "MASS") #先把"MASS" package叫進來
#requireNamespace
requireNamespace("MASS") #加這個語法
ls("package:MASS") #可以把package 裡dataset name list 在markdown
##   [1] "abbey"             "accdeaths"         "addterm"          
##   [4] "Aids2"             "Animals"           "anorexia"         
##   [7] "area"              "as.fractions"      "bacteria"         
##  [10] "bandwidth.nrd"     "bcv"               "beav1"            
##  [13] "beav2"             "biopsy"            "birthwt"          
##  [16] "Boston"            "boxcox"            "cabbages"         
##  [19] "caith"             "Cars93"            "cats"             
##  [22] "cement"            "chem"              "con2tr"           
##  [25] "contr.sdif"        "coop"              "corresp"          
##  [28] "cov.mcd"           "cov.mve"           "cov.rob"          
##  [31] "cov.trob"          "cpus"              "crabs"            
##  [34] "Cushings"          "DDT"               "deaths"           
##  [37] "denumerate"        "dose.p"            "drivers"          
##  [40] "dropterm"          "eagles"            "enlist"           
##  [43] "epil"              "eqscplot"          "farms"            
##  [46] "fbeta"             "fgl"               "fitdistr"         
##  [49] "forbes"            "fractions"         "frequency.polygon"
##  [52] "GAGurine"          "galaxies"          "gamma.dispersion" 
##  [55] "gamma.shape"       "gehan"             "genotype"         
##  [58] "geyser"            "gilgais"           "ginv"             
##  [61] "glm.convert"       "glm.nb"            "glmmPQL"          
##  [64] "hills"             "hist.FD"           "hist.scott"       
##  [67] "housing"           "huber"             "hubers"           
##  [70] "immer"             "Insurance"         "is.fractions"     
##  [73] "isoMDS"            "kde2d"             "lda"              
##  [76] "ldahist"           "leuk"              "lm.gls"           
##  [79] "lm.ridge"          "lmsreg"            "lmwork"           
##  [82] "loglm"             "loglm1"            "logtrans"         
##  [85] "lqs"               "lqs.formula"       "ltsreg"           
##  [88] "mammals"           "mca"               "mcycle"           
##  [91] "Melanoma"          "menarche"          "michelson"        
##  [94] "minn38"            "motors"            "muscle"           
##  [97] "mvrnorm"           "nclass.freq"       "neg.bin"          
## [100] "negative.binomial" "negexp.SSival"     "newcomb"          
## [103] "nlschools"         "npk"               "npr1"             
## [106] "Null"              "oats"              "OME"              
## [109] "painters"          "parcoord"          "petrol"           
## [112] "phones"            "Pima.te"           "Pima.tr"          
## [115] "Pima.tr2"          "polr"              "psi.bisquare"     
## [118] "psi.hampel"        "psi.huber"         "qda"              
## [121] "quine"             "Rabbit"            "rational"         
## [124] "renumerate"        "rlm"               "rms.curv"         
## [127] "rnegbin"           "road"              "rotifer"          
## [130] "Rubber"            "sammon"            "select"           
## [133] "Shepard"           "ships"             "shoes"            
## [136] "shrimp"            "shuttle"           "Sitka"            
## [139] "Sitka89"           "Skye"              "snails"           
## [142] "SP500"             "stdres"            "steam"            
## [145] "stepAIC"           "stormer"           "studres"          
## [148] "survey"            "synth.te"          "synth.tr"         
## [151] "theta.md"          "theta.ml"          "theta.mm"         
## [154] "topo"              "Traffic"           "truehist"         
## [157] "ucv"               "UScereal"          "UScrime"          
## [160] "VA"                "waders"            "whiteside"        
## [163] "width.SJ"          "write.matrix"      "wtloss"
help(ls("package:MASS")[92]) #就可以run了
## starting httpd help server ... done
ls(data(package = "MASS"))
## [1] "footer"  "header"  "results" "title"
data(package = "MASS")$results #發現這樣可以列出package中所有的datasets的Package、 LibPath、Item及Title
##       Package LibPath                                              Item       
##  [1,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Aids2"    
##  [2,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Animals"  
##  [3,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Boston"   
##  [4,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Cars93"   
##  [5,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Cushings" 
##  [6,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "DDT"      
##  [7,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "GAGurine" 
##  [8,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Insurance"
##  [9,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Melanoma" 
## [10,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "OME"      
## [11,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Pima.te"  
## [12,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Pima.tr"  
## [13,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Pima.tr2" 
## [14,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Rabbit"   
## [15,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Rubber"   
## [16,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "SP500"    
## [17,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Sitka"    
## [18,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Sitka89"  
## [19,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Skye"     
## [20,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "Traffic"  
## [21,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "UScereal" 
## [22,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "UScrime"  
## [23,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "VA"       
## [24,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "abbey"    
## [25,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "accdeaths"
## [26,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "anorexia" 
## [27,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "bacteria" 
## [28,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "beav1"    
## [29,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "beav2"    
## [30,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "biopsy"   
## [31,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "birthwt"  
## [32,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "cabbages" 
## [33,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "caith"    
## [34,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "cats"     
## [35,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "cement"   
## [36,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "chem"     
## [37,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "coop"     
## [38,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "cpus"     
## [39,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "crabs"    
## [40,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "deaths"   
## [41,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "drivers"  
## [42,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "eagles"   
## [43,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "epil"     
## [44,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "farms"    
## [45,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "fgl"      
## [46,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "forbes"   
## [47,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "galaxies" 
## [48,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "gehan"    
## [49,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "genotype" 
## [50,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "geyser"   
## [51,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "gilgais"  
## [52,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "hills"    
## [53,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "housing"  
## [54,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "immer"    
## [55,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "leuk"     
## [56,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "mammals"  
## [57,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "mcycle"   
## [58,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "menarche" 
## [59,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "michelson"
## [60,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "minn38"   
## [61,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "motors"   
## [62,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "muscle"   
## [63,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "newcomb"  
## [64,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "nlschools"
## [65,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "npk"      
## [66,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "npr1"     
## [67,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "oats"     
## [68,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "painters" 
## [69,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "petrol"   
## [70,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "phones"   
## [71,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "quine"    
## [72,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "road"     
## [73,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "rotifer"  
## [74,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "ships"    
## [75,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "shoes"    
## [76,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "shrimp"   
## [77,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "shuttle"  
## [78,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "snails"   
## [79,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "steam"    
## [80,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "stormer"  
## [81,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "survey"   
## [82,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "synth.te" 
## [83,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "synth.tr" 
## [84,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "topo"     
## [85,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "waders"   
## [86,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "whiteside"
## [87,] "MASS"  "C:/Users/Ching-Fang Wu/Documents/R/win-library/4.1" "wtloss"   
##       Title                                                           
##  [1,] "Australian AIDS Survival Data"                                 
##  [2,] "Brain and Body Weights for 28 Species"                         
##  [3,] "Housing Values in Suburbs of Boston"                           
##  [4,] "Data from 93 Cars on Sale in the USA in 1993"                  
##  [5,] "Diagnostic Tests on Patients with Cushing's Syndrome"          
##  [6,] "DDT in Kale"                                                   
##  [7,] "Level of GAG in Urine of Children"                             
##  [8,] "Numbers of Car Insurance claims"                               
##  [9,] "Survival from Malignant Melanoma"                              
## [10,] "Tests of Auditory Perception in Children with OME"             
## [11,] "Diabetes in Pima Indian Women"                                 
## [12,] "Diabetes in Pima Indian Women"                                 
## [13,] "Diabetes in Pima Indian Women"                                 
## [14,] "Blood Pressure in Rabbits"                                     
## [15,] "Accelerated Testing of Tyre Rubber"                            
## [16,] "Returns of the Standard and Poors 500"                         
## [17,] "Growth Curves for Sitka Spruce Trees in 1988"                  
## [18,] "Growth Curves for Sitka Spruce Trees in 1989"                  
## [19,] "AFM Compositions of Aphyric Skye Lavas"                        
## [20,] "Effect of Swedish Speed Limits on Accidents"                   
## [21,] "Nutritional and Marketing Information on US Cereals"           
## [22,] "The Effect of Punishment Regimes on Crime Rates"               
## [23,] "Veteran's Administration Lung Cancer Trial"                    
## [24,] "Determinations of Nickel Content"                              
## [25,] "Accidental Deaths in the US 1973-1978"                         
## [26,] "Anorexia Data on Weight Change"                                
## [27,] "Presence of Bacteria after Drug Treatments"                    
## [28,] "Body Temperature Series of Beaver 1"                           
## [29,] "Body Temperature Series of Beaver 2"                           
## [30,] "Biopsy Data on Breast Cancer Patients"                         
## [31,] "Risk Factors Associated with Low Infant Birth Weight"          
## [32,] "Data from a cabbage field trial"                               
## [33,] "Colours of Eyes and Hair of People in Caithness"               
## [34,] "Anatomical Data from Domestic Cats"                            
## [35,] "Heat Evolved by Setting Cements"                               
## [36,] "Copper in Wholemeal Flour"                                     
## [37,] "Co-operative Trial in Analytical Chemistry"                    
## [38,] "Performance of Computer CPUs"                                  
## [39,] "Morphological Measurements on Leptograpsus Crabs"              
## [40,] "Monthly Deaths from Lung Diseases in the UK"                   
## [41,] "Deaths of Car Drivers in Great Britain 1969-84"                
## [42,] "Foraging Ecology of Bald Eagles"                               
## [43,] "Seizure Counts for Epileptics"                                 
## [44,] "Ecological Factors in Farm Management"                         
## [45,] "Measurements of Forensic Glass Fragments"                      
## [46,] "Forbes' Data on Boiling Points in the Alps"                    
## [47,] "Velocities for 82 Galaxies"                                    
## [48,] "Remission Times of Leukaemia Patients"                         
## [49,] "Rat Genotype Data"                                             
## [50,] "Old Faithful Geyser Data"                                      
## [51,] "Line Transect of Soil in Gilgai Territory"                     
## [52,] "Record Times in Scottish Hill Races"                           
## [53,] "Frequency Table from a Copenhagen Housing Conditions Survey"   
## [54,] "Yields from a Barley Field Trial"                              
## [55,] "Survival Times and White Blood Counts for Leukaemia Patients"  
## [56,] "Brain and Body Weights for 62 Species of Land Mammals"         
## [57,] "Data from a Simulated Motorcycle Accident"                     
## [58,] "Age of Menarche in Warsaw"                                     
## [59,] "Michelson's Speed of Light Data"                               
## [60,] "Minnesota High School Graduates of 1938"                       
## [61,] "Accelerated Life Testing of Motorettes"                        
## [62,] "Effect of Calcium Chloride on Muscle Contraction in Rat Hearts"
## [63,] "Newcomb's Measurements of the Passage Time of Light"           
## [64,] "Eighth-Grade Pupils in the Netherlands"                        
## [65,] "Classical N, P, K Factorial Experiment"                        
## [66,] "US Naval Petroleum Reserve No. 1 data"                         
## [67,] "Data from an Oats Field Trial"                                 
## [68,] "The Painter's Data of de Piles"                                
## [69,] "N. L. Prater's Petrol Refinery Data"                           
## [70,] "Belgium Phone Calls 1950-1973"                                 
## [71,] "Absenteeism from School in Rural New South Wales"              
## [72,] "Road Accident Deaths in US States"                             
## [73,] "Numbers of Rotifers by Fluid Density"                          
## [74,] "Ships Damage Data"                                             
## [75,] "Shoe wear data of Box, Hunter and Hunter"                      
## [76,] "Percentage of Shrimp in Shrimp Cocktail"                       
## [77,] "Space Shuttle Autolander Problem"                              
## [78,] "Snail Mortality Data"                                          
## [79,] "The Saturated Steam Pressure Data"                             
## [80,] "The Stormer Viscometer Data"                                   
## [81,] "Student Survey Data"                                           
## [82,] "Synthetic Classification Problem"                              
## [83,] "Synthetic Classification Problem"                              
## [84,] "Spatial Topographic Data"                                      
## [85,] "Counts of Waders at 15 Sites in South Africa"                  
## [86,] "House Insulation: Whiteside's Data"                            
## [87,] "Weight Loss Data from an Obese Patient"

所以,package”MASS”中總計有87個items。