330exercise

Tim

2020-04-05

exercise1

## Loading required package: tools
## 'data.frame':    434 obs. of  4 variables:
##  $ ID      : Factor w/ 217 levels "1","2","3","4",..: 1 1 2 2 3 3 4 4 5 5 ...
##  $ status  : Factor w/ 2 levels "case","control": 1 2 1 2 1 2 1 2 1 2 ...
##  $ driver  : Factor w/ 2 levels "no","yes": 2 2 2 2 2 2 1 1 2 2 ...
##  $ suburban: Factor w/ 2 levels "no","yes": 2 1 2 2 1 2 1 1 1 2 ...
##   ID  status driver suburban
## 1  1    case    yes      yes
## 2  1 control    yes       no
## 3  2    case    yes      yes
## 4  2 control    yes      yes
## 5  3    case    yes       no
## 6  3 control    yes      yes
## [1] 434   4
##        ID          status    driver    suburban 
##  1      :  2   case   :217   no : 86   no :200  
##  2      :  2   control:217   yes:348   yes:234  
##  3      :  2                                    
##  4      :  2                                    
##  5      :  2                                    
##  6      :  2                                    
##  (Other):422
##   driver suburban  status frequency
## 1     no       no    case        26
## 2    yes       no    case        64
## 3     no      yes    case         6
## 4    yes      yes    case       121
## 5     no       no control        47
## 6    yes       no control        63
## 7     no      yes control         7
## 8    yes      yes control       100

exercise2

## 'data.frame':    50 obs. of  12 variables:
##  $ Population: num  3615 365 2212 2110 21198 ...
##  $ Income    : num  3624 6315 4530 3378 5114 ...
##  $ Illiteracy: num  2.1 1.5 1.8 1.9 1.1 0.7 1.1 0.9 1.3 2 ...
##  $ Life Exp  : num  69 69.3 70.5 70.7 71.7 ...
##  $ Murder    : num  15.1 11.3 7.8 10.1 10.3 6.8 3.1 6.2 10.7 13.9 ...
##  $ HS Grad   : num  41.3 66.7 58.1 39.9 62.6 63.9 56 54.6 52.6 40.6 ...
##  $ Frost     : num  20 152 15 65 20 166 139 103 11 60 ...
##  $ Area      : num  50708 566432 113417 51945 156361 ...
##  $ Murder    : num  13.2 10 8.1 8.8 9 7.9 3.3 5.9 15.4 17.4 ...
##  $ Assault   : int  236 263 294 190 276 204 110 238 335 211 ...
##  $ UrbanPop  : int  58 48 80 50 91 78 77 72 80 60 ...
##  $ Rape      : num  21.2 44.5 31 19.5 40.6 38.7 11.1 15.8 31.9 25.8 ...
##    Population        Income       Illiteracy       Life Exp    
##  Min.   :  365   Min.   :3098   Min.   :0.500   Min.   :67.96  
##  1st Qu.: 1080   1st Qu.:3993   1st Qu.:0.625   1st Qu.:70.12  
##  Median : 2838   Median :4519   Median :0.950   Median :70.67  
##  Mean   : 4246   Mean   :4436   Mean   :1.170   Mean   :70.88  
##  3rd Qu.: 4968   3rd Qu.:4814   3rd Qu.:1.575   3rd Qu.:71.89  
##  Max.   :21198   Max.   :6315   Max.   :2.800   Max.   :73.60  
##      Murder          HS Grad          Frost             Area       
##  Min.   : 1.400   Min.   :37.80   Min.   :  0.00   Min.   :  1049  
##  1st Qu.: 4.350   1st Qu.:48.05   1st Qu.: 66.25   1st Qu.: 36985  
##  Median : 6.850   Median :53.25   Median :114.50   Median : 54277  
##  Mean   : 7.378   Mean   :53.11   Mean   :104.46   Mean   : 70736  
##  3rd Qu.:10.675   3rd Qu.:59.15   3rd Qu.:139.75   3rd Qu.: 81162  
##  Max.   :15.100   Max.   :67.30   Max.   :188.00   Max.   :566432  
##      Murder          Assault         UrbanPop          Rape      
##  Min.   : 0.800   Min.   : 45.0   Min.   :32.00   Min.   : 7.30  
##  1st Qu.: 4.075   1st Qu.:109.0   1st Qu.:54.50   1st Qu.:15.07  
##  Median : 7.250   Median :159.0   Median :66.00   Median :20.10  
##  Mean   : 7.788   Mean   :170.8   Mean   :65.54   Mean   :21.23  
##  3rd Qu.:11.250   3rd Qu.:249.0   3rd Qu.:77.75   3rd Qu.:26.18  
##  Max.   :17.400   Max.   :337.0   Max.   :91.00   Max.   :46.00
##             Population      Income  Illiteracy    Life Exp      Murder
## Population  1.00000000  0.20822756  0.10762237 -0.06805195  0.34364275
## Income      0.20822756  1.00000000 -0.43707519  0.34025534 -0.23007761
## Illiteracy  0.10762237 -0.43707519  1.00000000 -0.58847793  0.70297520
## Life Exp   -0.06805195  0.34025534 -0.58847793  1.00000000 -0.78084575
## Murder      0.34364275 -0.23007761  0.70297520 -0.78084575  1.00000000
## HS Grad    -0.09848975  0.61993232 -0.65718861  0.58221620 -0.48797102
## Frost      -0.33215245  0.22628218 -0.67194697  0.26206801 -0.53888344
## Area        0.02254384  0.36331544  0.07726113 -0.10733194  0.22839021
## Murder      0.32024487 -0.21520501  0.70677564 -0.77849850  0.93369089
## Assault     0.31702281  0.04093255  0.51101299 -0.62665800  0.73976479
## UrbanPop    0.51260491  0.48053302 -0.06219936  0.27146824  0.01638255
## Rape        0.30523361  0.35738678  0.15459686 -0.26956828  0.57996132
##                HS Grad      Frost        Area      Murder     Assault
## Population -0.09848975 -0.3321525  0.02254384  0.32024487  0.31702281
## Income      0.61993232  0.2262822  0.36331544 -0.21520501  0.04093255
## Illiteracy -0.65718861 -0.6719470  0.07726113  0.70677564  0.51101299
## Life Exp    0.58221620  0.2620680 -0.10733194 -0.77849850 -0.62665800
## Murder     -0.48797102 -0.5388834  0.22839021  0.93369089  0.73976479
## HS Grad     1.00000000  0.3667797  0.33354187 -0.52159126 -0.23030510
## Frost       0.36677970  1.0000000  0.05922910 -0.54139702 -0.46823989
## Area        0.33354187  0.0592291  1.00000000  0.14808597  0.23120879
## Murder     -0.52159126 -0.5413970  0.14808597  1.00000000  0.80187331
## Assault    -0.23030510 -0.4682399  0.23120879  0.80187331  1.00000000
## UrbanPop    0.35868123 -0.2461862 -0.06154747  0.06957262  0.25887170
## Rape        0.27072504 -0.2792054  0.52495510  0.56357883  0.66524123
##               UrbanPop       Rape
## Population  0.51260491  0.3052336
## Income      0.48053302  0.3573868
## Illiteracy -0.06219936  0.1545969
## Life Exp    0.27146824 -0.2695683
## Murder      0.01638255  0.5799613
## HS Grad     0.35868123  0.2707250
## Frost      -0.24618618 -0.2792054
## Area       -0.06154747  0.5249551
## Murder      0.06957262  0.5635788
## Assault     0.25887170  0.6652412
## UrbanPop    1.00000000  0.4113412
## Rape        0.41134124  1.0000000
## corrplot 0.84 loaded