讀取檔案
# 以tab進行資料分隔,並讀取
dta <- read.table("http://www1.aucegypt.edu/faculty/hadi/RABE5/Data5/P005.txt",header = T,sep = "\t")
# 檢視資料
str(dta)
## 'data.frame': 38 obs. of 8 variables:
## $ City : Factor w/ 38 levels "Atlanta","Austin",..: 1 2 3 4 5 6 7 9 8 10 ...
## $ COL : int 169 143 339 173 99 363 253 117 294 291 ...
## $ PD : int 414 239 43 951 255 1257 834 162 229 1886 ...
## $ URate : num 13.6 11 23.7 21 16 24.4 39.2 31.5 18.2 31.5 ...
## $ Pop : int 1790128 396891 349874 2147850 411725 3914071 1326848 162304 164145 7015251 ...
## $ Taxes : int 5128 4303 4166 5001 3965 4928 4471 4813 4839 5408 ...
## $ Income: int 2961 1711 2122 4654 1620 5634 7213 5535 7224 6113 ...
## $ RTWL : int 1 1 0 0 1 0 0 0 1 0 ...
head(dta)
## City COL PD URate Pop Taxes Income RTWL
## 1 Atlanta 169 414 13.6 1790128 5128 2961 1
## 2 Austin 143 239 11.0 396891 4303 1711 1
## 3 Bakersfield 339 43 23.7 349874 4166 2122 0
## 4 Baltimore 173 951 21.0 2147850 5001 4654 0
## 5 Baton Rouge 99 255 16.0 411725 3965 1620 1
## 6 Boston 363 1257 24.4 3914071 4928 5634 0