diff --git a/Exercise09_script.R b/Exercise09_script.R new file mode 100644 index 0000000..e0e51d7 --- /dev/null +++ b/Exercise09_script.R @@ -0,0 +1,44 @@ +#Assumes working directory is set to Exercise09 directory + +library(ggplot2) +library(cowplot) + +#1 + +#loads txt file +q1_data <- read.table("q1_data.txt", header=TRUE, sep="\t") + +#generates scatterplot with trendline +ggplot(q1_data, aes(x = Height, y = Weight)) + + geom_point() + + xlab("Height (ft)") + + ylab("Weight (lbs)") + + stat_smooth(method="lm") + + theme_classic() + +#2 + +#loads txt file +q2_data <- read.table("data.txt", header=TRUE, sep=",") + +#generates barplot showing the mean observations for each region +ggplot(q2_data, aes(x=region,y=observations, fill=region)) + + stat_summary(fun=mean, geom= "bar") + + xlab("Region") + + ylab("Average Observations") + + theme_classic() + +#generates scatterplot showing observations for each region +ggplot(q2_data, aes(x=region,y=observations, color=region)) + + geom_jitter() + + xlab("Region") + + ylab("Observations") + + theme_classic() + +#The scatterplot and barplot do tell different stories. The barplot makes it seem like +#the observations are the same in all regions. However, looking at the scatterplot, +#we can see that the distribution of observations varies quite a bit between regions. +#For example, in the east there is a wide range of observations. In the north, the range +#of observations is small, yet the average is the same as the other regions. In the south, +#there seems to be two clusters of groups, a high and low obervation cluster. The west +#also showed a wide distribution of values. diff --git a/q1_data.txt b/q1_data.txt new file mode 100644 index 0000000..ec0f9a1 --- /dev/null +++ b/q1_data.txt @@ -0,0 +1,34 @@ +Height Weight +6.1 203 +4.8 122 +5.4 145 +5.2 135 +5.7 162 +5.8 164 +6.3 220 +5.5 151 +5.5 157 +5.2 123 +5.1 118 +6.2 199 +6.5 241 +5.6 157 +5.7 170 +4.8 111 +4.9 118 +5.2 130 +5.4 147 +5.5 153 +4.8 109 +4.9 117 +5 124 +5.1 125 +5.2 137 +5.3 135 +5.4 151 +5.5 158 +5.6 165 +5.7 169 +5.8 173 +5.9 183 +6 190 \ No newline at end of file