diff --git a/Exercise09Keenan.R b/Exercise09Keenan.R new file mode 100644 index 0000000..723e31b --- /dev/null +++ b/Exercise09Keenan.R @@ -0,0 +1,17 @@ +library(ggplot2) +#Question 1: +baseball<-read.table('HRvRBI2.txt', header = TRUE) +#This data shows the number of home runs and RBIs for the top 50 home run hitters +ggplot(baseball, aes(x=HR, y=RBI)) + geom_point()+geom_smooth(method = lm, se=FALSE) + +#Question 2: +data1 <- read.table('data.txt', header = TRUE, sep = ',') +ggplot(data1, aes(x=region, y=observations)) + geom_bar(stat = 'summary') + +ggplot(data1, aes(x=region, y=observations)) + geom_point()+geom_jitter() + +#The bar graph and scatter plots show very different stories. While the +#bar graph shows they all have similar means, the scatter plot shows the +#data is different based on region. For example, north is very compact +#whereas east and west are more spread out. South has two separate clusters +#and the mean is not really in either of them \ No newline at end of file diff --git a/HRvRBI2.txt b/HRvRBI2.txt new file mode 100644 index 0000000..bccbf2c --- /dev/null +++ b/HRvRBI2.txt @@ -0,0 +1 @@ +HR RBI 62 131 46 94 40 80 40 131 38 93 37 97 36 94 35 115 35 82 35 89 34 103 34 95 33 83 33 89 32 75 32 102 32 97 31 78 31 87 31 98 30 103 30 107 30 79 29 102 29 126 29 72 28 57 28 87 28 51 28 75 27 76 27 88 27 101 27 62 27 62 27 76 27 74 27 63 26 107 26 83 25 76 25 66 25 77 25 96 25 73 24 68 24 76 24 87 24 93 23 76 \ No newline at end of file