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(ggplot2)

Auto <- read.table("http://faculty.marshall.usc.edu/gareth-james/ISL/Auto.data", 
                   header=TRUE,
                   na.strings = "?")
head(Auto)
##   mpg cylinders displacement horsepower weight acceleration year origin
## 1  18         8          307        130   3504         12.0   70      1
## 2  15         8          350        165   3693         11.5   70      1
## 3  18         8          318        150   3436         11.0   70      1
## 4  16         8          304        150   3433         12.0   70      1
## 5  17         8          302        140   3449         10.5   70      1
## 6  15         8          429        198   4341         10.0   70      1
##                        name
## 1 chevrolet chevelle malibu
## 2         buick skylark 320
## 3        plymouth satellite
## 4             amc rebel sst
## 5               ford torino
## 6          ford galaxie 500
#problem 1
str(Auto)
## 'data.frame':    397 obs. of  9 variables:
##  $ mpg         : num  18 15 18 16 17 15 14 14 14 15 ...
##  $ cylinders   : int  8 8 8 8 8 8 8 8 8 8 ...
##  $ displacement: num  307 350 318 304 302 429 454 440 455 390 ...
##  $ horsepower  : num  130 165 150 150 140 198 220 215 225 190 ...
##  $ weight      : num  3504 3693 3436 3433 3449 ...
##  $ acceleration: num  12 11.5 11 12 10.5 10 9 8.5 10 8.5 ...
##  $ year        : int  70 70 70 70 70 70 70 70 70 70 ...
##  $ origin      : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ name        : chr  "chevrolet chevelle malibu" "buick skylark 320" "plymouth satellite" "amc rebel sst" ...
#every thing is quantitative except for the name of the product

#problem 2
#mpg
range(Auto[,1])
## [1]  9.0 46.6
#cylinders
range(Auto[,2])
## [1] 3 8
#displacement
range(Auto[,3])
## [1]  68 455
#horsepower
range(Auto[,4])
## [1] NA NA
#weight
range(Auto[,5])
## [1] 1613 5140
#acceleration
range(Auto[,6])
## [1]  8.0 24.8
#year
range(Auto[,7])
## [1] 70 82
#origin
range(Auto[,8])
## [1] 1 3
#problem 3
#mpg
mean(Auto[,1])
## [1] 23.51587
sd(Auto[,1])
## [1] 7.825804
#cylinders
mean(Auto[,2])
## [1] 5.458438
sd(Auto[,2])
## [1] 1.701577
#displacement
mean(Auto[,3])
## [1] 193.5327
sd(Auto[,3])
## [1] 104.3796
#horsepower
mean(Auto[,4])
## [1] NA
sd(Auto[,4])
## [1] NA
#weight
mean(Auto[,5])
## [1] 2970.262
sd(Auto[,5])
## [1] 847.9041
#acceleration
mean(Auto[,6])
## [1] 15.55567
sd(Auto[,6])
## [1] 2.749995
#year
mean(Auto[,7])
## [1] 75.99496
sd(Auto[,7])
## [1] 3.690005
#origin
mean(Auto[,8])
## [1] 1.574307
sd(Auto[,8])
## [1] 0.8025495
#problem $
ten85= rbind(Auto[1:9,],Auto[86:397,])

#problem 3
#mpg
mean(ten85[,1])
## [1] 24.43863
sd(ten85[,1])
## [1] 7.908184
#cylinders
mean(ten85[,2])
## [1] 5.370717
sd(ten85[,2])
## [1] 1.653486
#displacement
mean(ten85[,3])
## [1] 187.0498
sd(ten85[,3])
## [1] 99.63539
#horsepower
mean(ten85[,4])
## [1] NA
sd(ten85[,4])
## [1] NA
#weight
mean(ten85[,5])
## [1] 2933.963
sd(ten85[,5])
## [1] 810.6429
#acceleration
mean(ten85[,6])
## [1] 15.72305
sd(ten85[,6])
## [1] 2.680514
#year
mean(ten85[,7])
## [1] 77.15265
sd(ten85[,7])
## [1] 3.11123
#origin
mean(ten85[,8])
## [1] 1.598131
sd(ten85[,8])
## [1] 0.8161627
#Ranges
#mpg
range(ten85[,1])
## [1] 11.0 46.6
#cylinders
range(ten85[,2])
## [1] 3 8
#displacement
range(ten85[,3])
## [1]  68 455
#horsepower
range(ten85[,4])
## [1] NA NA
#weight
range(ten85[,5])
## [1] 1649 4997
#acceleration
range(ten85[,6])
## [1]  8.5 24.8
#year
range(ten85[,7])
## [1] 70 82
#origin
range(ten85[,8])
## [1] 1 3
#problem 4
pairs(Auto[,1:8])

# from this i've gathered there is a correlation between the following variables mpg, displacement, horsepower,weight, and acceleration.
#problem 5
college<-read.csv("http://faculty.marshall.usc.edu/gareth-james/ISL/College.csv",header=TRUE)

rownames(college) <- college[,1]
View(college)
college <- college[,-1]
View(college)
#part C.A
summary(college)
##    Private               Apps           Accept          Enroll    
##  Length:777         Min.   :   81   Min.   :   72   Min.   :  35  
##  Class :character   1st Qu.:  776   1st Qu.:  604   1st Qu.: 242  
##  Mode  :character   Median : 1558   Median : 1110   Median : 434  
##                     Mean   : 3002   Mean   : 2019   Mean   : 780  
##                     3rd Qu.: 3624   3rd Qu.: 2424   3rd Qu.: 902  
##                     Max.   :48094   Max.   :26330   Max.   :6392  
##    Top10perc       Top25perc      F.Undergrad     P.Undergrad     
##  Min.   : 1.00   Min.   :  9.0   Min.   :  139   Min.   :    1.0  
##  1st Qu.:15.00   1st Qu.: 41.0   1st Qu.:  992   1st Qu.:   95.0  
##  Median :23.00   Median : 54.0   Median : 1707   Median :  353.0  
##  Mean   :27.56   Mean   : 55.8   Mean   : 3700   Mean   :  855.3  
##  3rd Qu.:35.00   3rd Qu.: 69.0   3rd Qu.: 4005   3rd Qu.:  967.0  
##  Max.   :96.00   Max.   :100.0   Max.   :31643   Max.   :21836.0  
##     Outstate       Room.Board       Books           Personal   
##  Min.   : 2340   Min.   :1780   Min.   :  96.0   Min.   : 250  
##  1st Qu.: 7320   1st Qu.:3597   1st Qu.: 470.0   1st Qu.: 850  
##  Median : 9990   Median :4200   Median : 500.0   Median :1200  
##  Mean   :10441   Mean   :4358   Mean   : 549.4   Mean   :1341  
##  3rd Qu.:12925   3rd Qu.:5050   3rd Qu.: 600.0   3rd Qu.:1700  
##  Max.   :21700   Max.   :8124   Max.   :2340.0   Max.   :6800  
##       PhD            Terminal       S.F.Ratio      perc.alumni   
##  Min.   :  8.00   Min.   : 24.0   Min.   : 2.50   Min.   : 0.00  
##  1st Qu.: 62.00   1st Qu.: 71.0   1st Qu.:11.50   1st Qu.:13.00  
##  Median : 75.00   Median : 82.0   Median :13.60   Median :21.00  
##  Mean   : 72.66   Mean   : 79.7   Mean   :14.09   Mean   :22.74  
##  3rd Qu.: 85.00   3rd Qu.: 92.0   3rd Qu.:16.50   3rd Qu.:31.00  
##  Max.   :103.00   Max.   :100.0   Max.   :39.80   Max.   :64.00  
##      Expend        Grad.Rate     
##  Min.   : 3186   Min.   : 10.00  
##  1st Qu.: 6751   1st Qu.: 53.00  
##  Median : 8377   Median : 65.00  
##  Mean   : 9660   Mean   : 65.46  
##  3rd Qu.:10830   3rd Qu.: 78.00  
##  Max.   :56233   Max.   :118.00
#part C.b
pairs(college[,2:10])