Lesson 6 start
This commit is contained in:
parent
791d543af7
commit
9945ad26ef
@ -9,7 +9,12 @@ Notes:
|
||||
### 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
|
||||
Response:
|
||||
|
||||
***
|
||||
The price increases as the carat increases but it also gains more variability
|
||||
|
||||
### Frances Gerety
|
||||
Notes:
|
||||
|
||||
#### A diamonds is
|
||||
|
||||
|
||||
***
|
||||
Forever
|
||||
|
||||
### The Rise of Diamonds
|
||||
Notes:
|
||||
@ -37,14 +40,14 @@ Notes:
|
||||
|
||||
```{r ggpairs Function}
|
||||
# install these if necessary
|
||||
install.packages('GGally')
|
||||
install.packages('scales')
|
||||
install.packages('memisc')
|
||||
install.packages('lattice')
|
||||
install.packages('MASS')
|
||||
install.packages('car')
|
||||
install.packages('reshape')
|
||||
install.packages('plyr')
|
||||
#install.packages('GGally')
|
||||
#install.packages('scales')
|
||||
#install.packages('memisc')
|
||||
#install.packages('lattice')
|
||||
#install.packages('MASS')
|
||||
#install.packages('car')
|
||||
#install.packages('reshape')
|
||||
#install.packages('plyr')
|
||||
|
||||
# load the ggplot graphics package and the others
|
||||
library(ggplot2)
|
||||
@ -55,19 +58,32 @@ library(memisc)
|
||||
# sample 10,000 diamonds from the data set
|
||||
set.seed(20022012)
|
||||
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?
|
||||
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
|
||||
Notes:
|
||||
|
||||
```{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
|
||||
Notes:
|
||||
|
||||
***
|
||||
There are 2 categories of diamond buyers that are looking for different types
|
||||
|
||||
### Scatterplot Transformation
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user