Lesson 6 start

This commit is contained in:
Dusty.P 2018-05-31 00:35:10 -08:00
parent 791d543af7
commit 9945ad26ef

View File

@ -9,7 +9,12 @@ Notes:
### Scatterplot Review ### Scatterplot Review
```{r Scatterplot Review} ```{r Scatterplot Review}
library(ggplot2)
data(diamonds)
ggplot(aes(x = carat, y = price), data = diamonds) +
geom_point() +
xlim(0, quantile(diamonds$carat, 0.99)) +
ylim(0, quantile(diamonds$price, 0.99))
``` ```
*** ***
@ -17,15 +22,13 @@ Notes:
### Price and Carat Relationship ### Price and Carat Relationship
Response: Response:
*** The price increases as the carat increases but it also gains more variability
### Frances Gerety ### Frances Gerety
Notes: Notes:
#### A diamonds is #### A diamonds is
Forever
***
### The Rise of Diamonds ### The Rise of Diamonds
Notes: Notes:
@ -37,14 +40,14 @@ Notes:
```{r ggpairs Function} ```{r ggpairs Function}
# install these if necessary # install these if necessary
install.packages('GGally') #install.packages('GGally')
install.packages('scales') #install.packages('scales')
install.packages('memisc') #install.packages('memisc')
install.packages('lattice') #install.packages('lattice')
install.packages('MASS') #install.packages('MASS')
install.packages('car') #install.packages('car')
install.packages('reshape') #install.packages('reshape')
install.packages('plyr') #install.packages('plyr')
# load the ggplot graphics package and the others # load the ggplot graphics package and the others
library(ggplot2) library(ggplot2)
@ -55,19 +58,32 @@ library(memisc)
# sample 10,000 diamonds from the data set # sample 10,000 diamonds from the data set
set.seed(20022012) set.seed(20022012)
diamond_samp <- diamonds[sample(1:length(diamonds$price), 10000), ] diamond_samp <- diamonds[sample(1:length(diamonds$price), 10000), ]
ggpairs(diamond_samp, params = c(shape = I('.'), outlier.shape = I('.'))) ggpairs(diamond_samp,
lower = list(continuous = wrap("points", shape = I('.'))),
upper = list(combo = wrap("box", outlier.shape = I('.'))))
``` ```
What are some things you notice in the ggpairs output? What are some things you notice in the ggpairs output?
Response: Response:
*** There seems to be some Clarity and Colors that draw a higher price but besides that the size seems to have the largest correlation.
### The Demand of Diamonds ### The Demand of Diamonds
Notes: Notes:
```{r The Demand of Diamonds} ```{r The Demand of Diamonds}
library(gridExtra)
plot1 <- ggplot(aes(x = price), data = diamonds) +
geom_histogram() +
ggtitle('Price')
plot2 <- ggplot(aes(x = price), data = diamonds) +
geom_histogram() +
scale_x_log10() +
ggtitle('Price (log10)')
grid.arrange(plot1, plot2, ncol = 2)
``` ```
*** ***
@ -75,7 +91,7 @@ Notes:
### Connecting Demand and Price Distributions ### Connecting Demand and Price Distributions
Notes: Notes:
*** There are 2 categories of diamond buyers that are looking for different types
### Scatterplot Transformation ### Scatterplot Transformation