From 9945ad26ef91fe4cd22dc887cea3419ec51676b4 Mon Sep 17 00:00:00 2001 From: "Dusty.P" Date: Thu, 31 May 2018 00:35:10 -0800 Subject: [PATCH] Lesson 6 start --- lesson6/lesson6_student.rmd | 48 ++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/lesson6/lesson6_student.rmd b/lesson6/lesson6_student.rmd index bd4f51e..a66d7db 100644 --- a/lesson6/lesson6_student.rmd +++ b/lesson6/lesson6_student.rmd @@ -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