Question 1

#Create tibble of mtcars
myMtcars=as_tibble(mtcars)
#Create factors
myMtcars$am=factor(myMtcars$am)
myMtcars$gear=factor(myMtcars$gear)

Question 2

#List the structure of myMtcars
str(myMtcars)
## tibble [32 x 11] (S3: tbl_df/tbl/data.frame)
##  $ mpg : num [1:32] 21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
##  $ cyl : num [1:32] 6 6 4 6 8 6 8 4 4 6 ...
##  $ disp: num [1:32] 160 160 108 258 360 ...
##  $ hp  : num [1:32] 110 110 93 110 175 105 245 62 95 123 ...
##  $ drat: num [1:32] 3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
##  $ wt  : num [1:32] 2.62 2.88 2.32 3.21 3.44 ...
##  $ qsec: num [1:32] 16.5 17 18.6 19.4 17 ...
##  $ vs  : num [1:32] 0 0 1 1 0 1 0 1 1 1 ...
##  $ am  : Factor w/ 2 levels "0","1": 2 2 2 1 1 1 1 1 1 1 ...
##  $ gear: Factor w/ 3 levels "3","4","5": 2 2 2 1 1 1 1 2 2 2 ...
##  $ carb: num [1:32] 4 4 1 1 2 1 4 2 2 4 ...

Question 3

myMtcars=myMtcars%>%mutate(am_name=ifelse(am==0,"Automatic","Manual"))
myMtcars$am_name
##  [1] "Manual"    "Manual"    "Manual"    "Automatic" "Automatic" "Automatic"
##  [7] "Automatic" "Automatic" "Automatic" "Automatic" "Automatic" "Automatic"
## [13] "Automatic" "Automatic" "Automatic" "Automatic" "Automatic" "Manual"   
## [19] "Manual"    "Manual"    "Automatic" "Automatic" "Automatic" "Automatic"
## [25] "Automatic" "Manual"    "Manual"    "Manual"    "Manual"    "Manual"   
## [31] "Manual"    "Manual"

Question 4

#Create the graph
carplot=myMtcars%>%ggplot(aes(x=wt,y=mpg))
carplot+geom_point(aes(color=gear))+labs(x="Weight",y="Miles per Gallon",color="Gears")+stat_smooth(method="lm",se=FALSE)+facet_grid(~am_name)
## `geom_smooth()` using formula 'y ~ x'

Question 5

#Run code as shown in assignment
ggpairs(mtcars)

Question 6

Values greater than the absolute value: (wt,dsp), (dsp,cyl), (hp,cyl).