diff --git a/Exercise9.R b/Exercise9.R new file mode 100644 index 0000000..d6d3029 --- /dev/null +++ b/Exercise9.R @@ -0,0 +1,37 @@ +# Nathan Kroeze +# Exercise 9 +# 11/18/2022 + +library(tidyverse) + +# Q1: Enter those data into a text file or Excel and then +# save a text file, and write a script that loads this text file and produces a scatter plot of those two variables +# that includes a trend line. + +setwd("C:/Users/Natha/Desktop/Biocomputing/Exercise09/") +researchData <- read.csv("researchData.csv") +researchData <- researchData[,-1] #remove count column + +ggplot(researchData, aes(d13C,d15N)) + + geom_jitter() + geom_smooth(method = "lm") + + labs(title = "Research Isotope Data") + +# Q2: Write a script that generates two figures that sumamrize the data. First, show +# a barplot of the means of the four populations. Second, show a scatter plot of all of the observations. + +dataEx <- read.table("data.txt",header = TRUE, sep = ",") + +ggplot(data = dataEx, aes(x=region,y=observations)) + + stat_summary(geom = "bar",fun = "mean") + + xlab("Region") + ylab("Means of Populations") + theme_bw() + +ggplot(data = dataEx, aes(x=region,y=observations)) + + geom_jitter() + + xlab("Region") + ylab("Observations") + theme_bw() + +# Answers: +# The plots tell different stories because the bar plot demonstrates that the average population for +# each region is roughly the same, however the scatter plot shows that the variance in these data are not +# consistent across regions. For example, the western region has a wide variance of observations but +# the northern region has a narrow densely populated band. This difference is lost in the bar plot and +# would have been missed if not plotted separately. diff --git a/researchData.txt b/researchData.txt new file mode 100644 index 0000000..f780f66 --- /dev/null +++ b/researchData.txt @@ -0,0 +1,242 @@ +"d15N" "d13C" +"1" 5.3 -28.9 +"2" 4 -28.8 +"3" 3.1 -28.8 +"4" 3.5 -25.1 +"5" 3.1 -27.1 +"6" 3.2 -28.1 +"7" 2.2 -28.1 +"8" 3 -27.4 +"9" 2.4 -28.7 +"10" 3 -26.2 +"11" 3 -26.7 +"12" 3.1 -27.4 +"13" 4.5 -26.4 +"14" 3.3 -27.8 +"15" 3.3 -28.5 +"16" 3.2 -27.3 +"17" 3 -26.4 +"18" 3 -27.4 +"19" 2.8 -22.7 +"20" 3.9 -23.3 +"21" 3.4 -22.4 +"22" 3.7 -28 +"23" 3.6 -28.8 +"24" 3.3 -28.4 +"25" 5.3 -28 +"26" 3.5 -28.2 +"27" 3.5 -29.1 +"28" 3.1 -28.8 +"29" 3.2 -28.9 +"30" 2.9 -29 +"31" 4.2 -20.3 +"32" 4.2 -22.6 +"33" 4.4 -24.4 +"34" 2.8 -26.6 +"35" 2.8 -28.4 +"36" 3.1 -28.5 +"37" 5 -27.5 +"38" 3.7 -26.1 +"39" 2.7 -28.5 +"40" 2.5 -28.9 +"41" 2.9 -27.5 +"42" 2.1 -28.9 +"43" 1.2 -26.8 +"44" 2.2 -28.5 +"45" 2.2 -28.3 +"46" 3.6 -15.9 +"47" 3.8 -16.8 +"48" 3 -22.3 +"49" 5.5 -24.7 +"50" 3.6 -26.7 +"51" 3 -27.2 +"52" 3.5 -28.1 +"53" 3 -28.6 +"54" 3 -29.2 +"55" 1.9 -27.3 +"56" 3 -28.7 +"57" 2.8 -29.2 +"58" 2.1 -26.8 +"59" 2.7 -28.5 +"60" 2.4 -28.5 +"61" 5.9 -27.2 +"62" 4.4 -27 +"63" 3.8 -28.1 +"64" 3.9 -26.4 +"65" 4.1 -27.1 +"66" 4.2 -27.8 +"67" 2.9 -26.6 +"68" 3 -27 +"69" 2.9 -28 +"70" 3.1 -27.6 +"71" 3 -28.8 +"72" 2.5 -29.1 +"73" 6.1 -20 +"74" 3.3 -28.1 +"75" 3.2 -28.5 +"76" 3.6 -28.2 +"77" 4 -28.2 +"78" 3.7 -28.6 +"79" 1.4 -28.3 +"80" 1.5 -27.4 +"81" 2.4 -28.2 +"82" 3.4 -23 +"83" 3.9 -22.9 +"84" 3.5 -24.6 +"85" 1.5 -27.9 +"86" 3.6 -28.5 +"87" 2.7 -28.5 +"88" 2.9 -26.8 +"89" 2.9 -28.1 +"90" 2.9 -28.6 +"91" 2.5 -26.8 +"92" 2.3 -29.1 +"93" 2.6 -28.9 +"94" 2.2 -27.6 +"95" 2.5 -28.6 +"96" 2.7 -28.9 +"97" 3.4 -24.8 +"98" 3.9 -27.1 +"99" 4.4 -28.3 +"100" 2.1 -26.1 +"101" 3.2 -28.8 +"102" 3.4 -28.8 +"103" 2.6 -27.5 +"104" 2.9 -29.2 +"105" 2.9 -29.1 +"106" 2.4 -28.9 +"107" 2.8 -28.8 +"108" 2.8 -29 +"109" 2.9 -28.9 +"110" 3.3 -29.1 +"111" 3.9 -29.1 +"112" 3.1 -28.2 +"113" 2.9 -29.2 +"114" 3 -29.5 +"115" 3.4 -28.9 +"116" 3 -27.9 +"117" 3.2 -28.7 +"118" 2.3 -28.2 +"119" 2.2 -29.1 +"120" 2.5 -29.3 +"121" 3.3 -28 +"122" 3 -29.1 +"123" 3.5 -29 +"124" 3.5 -27.8 +"125" 3.3 -30.7 +"126" 2.6 -30.7 +"127" 3.2 -27 +"128" 2.9 -27.6 +"129" 2.7 -28.4 +"130" 3 -26.9 +"131" 2.7 -28.2 +"132" 2 -29.3 +"133" 3 -26.2 +"134" 3.2 -28.1 +"135" 4 -28.3 +"136" 3.1 -23 +"137" 3.5 -27.9 +"138" 3.3 -28.1 +"139" 2.9 -25.4 +"140" 2.6 -26.9 +"141" 2.4 -28.2 +"142" 3.4 -24.4 +"143" 3.7 -25.4 +"144" 3.1 -26.5 +"145" 2.7 -27.9 +"146" 2.7 -28.6 +"147" 3 -28.5 +"148" 3.8 -22.3 +"149" 4 -26.3 +"150" 3.5 -27 +"151" 2.8 -27.7 +"152" 3 -28.3 +"153" 2.6 -28.5 +"154" 3.2 -23.7 +"155" 3.5 -25.2 +"156" 3.2 -26.9 +"157" 1.7 -26.2 +"158" 2.5 -27.2 +"159" 3.8 -28.4 +"160" 3.9 -25.6 +"161" 3.4 -27.1 +"162" 3 -26.8 +"163" 3.4 -26.1 +"164" 3.3 -27.8 +"165" 3.6 -28.2 +"166" 2.4 -28 +"167" 2.3 -29 +"168" 2.5 -29.1 +"169" 2.7 -23.4 +"170" 2.8 -26.5 +"171" 3.4 -28 +"172" 2.8 -26.6 +"173" 2.9 -26.7 +"174" 2 -29.2 +"175" 2 -27.4 +"176" 2.5 -28.4 +"177" 1.9 -28.5 +"178" 2.3 -29.1 +"179" 2.8 -27.5 +"180" 2.3 -28.8 +"181" 2.6 -25.3 +"182" 2.6 -24.5 +"183" 2.9 -27.8 +"184" 4.2 -29.4 +"185" 3.7 -29.9 +"186" 2.7 -29.5 +"187" 3.6 -14.5 +"188" 3.2 -14.4 +"189" 3.3 -14.3 +"190" 3.7 -14.3 +"191" 3.7 -13.8 +"192" 3.8 -14.3 +"193" 2.9 -30.1 +"194" 3.8 -30.3 +"195" 3.3 -30.1 +"196" 3 -29.8 +"197" 4.4 -29.5 +"198" 2.9 -29.4 +"199" 3.4 -14.5 +"200" 3.2 -13.9 +"201" 2.8 -14.2 +"202" 2.3 -29.8 +"203" 2 -30 +"204" 1.4 -29.2 +"205" 3.4 -13.9 +"206" 2.3 -13.4 +"207" 1.9 -13.6 +"208" 1.5 -29.6 +"209" 3 -30.2 +"210" 1.3 -29.6 +"211" 4 -14.5 +"212" 3.3 -14.1 +"213" 3 -14.2 +"214" 3.1 -29.5 +"215" 2.9 -31.2 +"216" 3.3 -13.9 +"217" 3.3 -29.3 +"218" 1.8 -29.5 +"219" 3.8 -14.3 +"220" 2.3 -29.5 +"221" 5.2 -29.6 +"222" 4.7 -14.1 +"223" 2.6 -29.8 +"224" 2.1 -29.4 +"225" 2.7 -28.7 +"226" 3.6 -30.2 +"227" 2.6 -29.8 +"228" 2.1 -28.7 +"229" 2.9 -29.2 +"230" 1.7 -29.7 +"231" 2.9 -29.6 +"232" 3.5 -14.2 +"233" 3.5 -29 +"234" 3.4 -27.7 +"235" 1.8 -29.3 +"236" 2.4 -28.8 +"237" 2.2 -28.6 +"238" 2.4 -29.1 +"239" 2.9 -25.7 +"240" 3.1 -27.8 +"241" 3 -28.1