From 47209d5a96ff9c228b92456f1d165b8c62b72b81 Mon Sep 17 00:00:00 2001 From: KATIE BRELAND Date: Thu, 11 May 2017 14:03:26 -0700 Subject: [PATCH] completed m18 exercise #1 --- .DS_Store | Bin 0 -> 6148 bytes exercise-1/.DS_Store | Bin 0 -> 6148 bytes exercise-1/exercise.R | 15 +++++++++++++-- exercise-1/scripts/BuildScatter.R | 9 +++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 .DS_Store create mode 100644 exercise-1/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..6f2d2473840cb3796ba0b74bae23dbfad13fd3a1 GIT binary patch literal 6148 zcmeHK&2G~`5T0#A>l6?!`KldaKwWKnU`M zcL3giN8t&05FP-&{Q>z8#0ep~Bh7xZyEAL=x8q$e5wXE6bci}cWI+YCHc&K(=oea( z72R?H$mAH;$Qj4{Fo=0j^EM5J0mHz*#(?;C*C?b3oe-z;_bWDqThOcDq{vq<`rasf z>%#ZbZ+v&kzHGDNyMZ@&37yg*MU=v-y$gHyCo#c1J=Ocq=ioGs(yZJ4!d6yW=hoJ( zcH3%Sw4Qs%eC}m_HcJQo^r@^x;Uv)ZBhKTWwjVr>CiDHy7g%6P0pF;}7@n+vHPOB=!}4#RYAOsVtUEg7<|aXo~5T7g#1k zF=n0a(wO#WMEA*~QQ2FjL($tpIy%%x5=5|$D6RO5R4Dql=^;kGLqoa;ypEW#5+UYY zj6n6Qi%vJ|{8=Z$%-=9z7^pEI_6Hj((AAhLlv@W1c?AHr&@2VE_!ST_wnkTDt`I#C zrb2-#l<6x5Q{ia0wV$goSE#~?>B|SxPiFdt!sOF2zAfE}xe85b7%&W!8CX@-jyV5E zzrO#MgG|jZU>NwX7+|fTHymI}`fRODPMozi^Z+VE_~i;^2nu~1OG6yRTTm(JvxNb4 VHRcM@0x>@Vk_J;42L37o-vLtX)o=g+ literal 0 HcmV?d00001 diff --git a/exercise-1/.DS_Store b/exercise-1/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..6c51ab9dc08de3925462f28d62ae31e21bc8124d GIT binary patch literal 6148 zcmeHKOG-mQ5UkdKfo!sLIalxoLr6}L3y28;L5TQt|5l#Mqow+@Fg&x13#A%*YNn@a zhN;Et*8ptwv3~%T0OoW@eEKjo-*=zbO+}1I=NYef$8gvWyQkwM`{#gj?=WD8H#~pm zA76Y+CIzH`6p#W^Knh%0fhw@`#g)(1aZ*4E{Cx%d`_Sl)y>Lv7PX~u+0f;k(!#Iy# zg4jGj?1f_@BQ#4YF{xH9h9#ZxR(ZW}OiVhgnh&d+tvVEo+j)MAbXZT+CH(cL%?3Wq4i#3;vHcsah0 cq|9qR=YB676NAop(24pPa9w0l;I|bx0Xp#&vH$=8 literal 0 HcmV?d00001 diff --git a/exercise-1/exercise.R b/exercise-1/exercise.R index 66c7fac..32123bd 100644 --- a/exercise-1/exercise.R +++ b/exercise-1/exercise.R @@ -1,9 +1,20 @@ # Exercise 1: Loading functions # Set your directory - +setwd('~/Desktop/Info/m18-shiny/') # Source your BuildScatter.r script, exposing your BuildScatter function - +source('./exercise-1/scripts/BuildScatter.R') # Use your BuildScatter function to draw a well labeled ggplot scatterplot of the iris data +library(ggplot2) + + +BuildScatter(data = iris, + xVar = 'Sepal.Length', + yVar = 'Sepal.Width', + colorVar = 'Species', + title = 'Iris Dataset', + xLab = 'Sepal Length', + yLab = 'Sepal Width' + ) \ No newline at end of file diff --git a/exercise-1/scripts/BuildScatter.R b/exercise-1/scripts/BuildScatter.R index 8ce59c6..d6ee536 100644 --- a/exercise-1/scripts/BuildScatter.R +++ b/exercise-1/scripts/BuildScatter.R @@ -8,3 +8,12 @@ # - Title of the plot (set a default of "Title") # - Label for the x axis (set a default of "X Title") # - Label for the y axis (set a default of "Y Title") + +library(ggplot2) +BuildScatter<- function(data, xVar, yVar, colorVar, title = "Title", xLab ="X title", yLab = "y title"){ + p<- ggplot(data = data) + + geom_point(mapping = aes(x = data[ ,xVar], y = data[ ,yVar], color = data[,colorVar])) + + labs(title = title, x = xLab, y = yLab) + + p +}