diff --git a/Ex09DataFinal.csv b/Ex09DataFinal.csv new file mode 100644 index 0000000..95f01f5 --- /dev/null +++ b/Ex09DataFinal.csv @@ -0,0 +1,11 @@ +Name,Age,Net Worth (millions) +Billie Eilish ,20,30 +Yungblud,25,4 +Kevin Abstract,26,1.5 +Kehlani,27,12 +Phoebe Bridgers,28,5 +Joji,30,8 +Jessie Reyez,31,1.4 +Rihanna,34,1400 +Kendrick Lamar,35,75 +Drake,36,250 \ No newline at end of file diff --git a/Exercise09Data - Sheet1.csv b/Exercise09Data - Sheet1.csv new file mode 100644 index 0000000..95f01f5 --- /dev/null +++ b/Exercise09Data - Sheet1.csv @@ -0,0 +1,11 @@ +Name,Age,Net Worth (millions) +Billie Eilish ,20,30 +Yungblud,25,4 +Kevin Abstract,26,1.5 +Kehlani,27,12 +Phoebe Bridgers,28,5 +Joji,30,8 +Jessie Reyez,31,1.4 +Rihanna,34,1400 +Kendrick Lamar,35,75 +Drake,36,250 \ No newline at end of file diff --git a/Exercise09Final.R b/Exercise09Final.R new file mode 100644 index 0000000..e76b68c --- /dev/null +++ b/Exercise09Final.R @@ -0,0 +1,48 @@ +#Exercise09 + +#Part1 +#set directory +setwd("/Users/romanfresquez/Tutorials/Exercise09") +#create variable with data on the net worth of singers as their age increases +artist.worth<-read.csv("Ex09DataFinal.csv") + +#load the plotting packages +library(ggplot2) +library(cowplot) + +#plot age against net worth and add a linear trend line +ggplot(data=artist.worth, + aes(x=Age,y=Net.Worth..millions.))+ + geom_point()+ + stat_smooth(method="lm")+ + theme_classic() + +#Part 2 +#create variable with data from data.txt +location.data<-read.csv("data.txt") +#find out the column names by pulling the first 10 lines +location.data[c(1:10),] + +#create bar graph of data points +ggplot(data=location.data, aes(x=region,y=observations))+ + stat_summary(fun.y=mean, + geom="bar") + +#following is for checking that my averages on the bar graph were correct +#create variables for each region data points +north<-location.data[location.data$region=="north",] +east<-location.data[location.data$region=="east",] +south<-location.data[location.data$region=="south",] +west<-location.data[location.data$region=="west",] +#check the averages with the bar graph +north.mean<-mean(north$observations) +east.mean<-mean(east$observations) +south.mean<-mean(south$observations) +west.mean<-mean(west$observations) + +#scatter plot for observartions +ggplot(data=location.data, aes(x=region,y=observations))+ + geom_jitter()+ + theme_classic() + +