Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Exercise09Keenan.R
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions HRvRBI2.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down