diff --git a/Babson_03.Rmd b/Babson_03.Rmd new file mode 100644 index 0000000..9e7bd3b --- /dev/null +++ b/Babson_03.Rmd @@ -0,0 +1,89 @@ +--- +title: 'Homework 3: Data Visualization' +output: html_document +--- + +**1)** Complete problems 10 and 17-18 on pg. 109-111. Use R where possible. Data sets (so you don’t have to type things in) are available at http://www.zoology.ubc.ca/~whitlock/ABD/teaching/datasets.html. + +```{r} +### Question 10 +genes <- read.csv('./data/04q11NumberGenesRegulated.csv') + +### a) 95% CI for the population mean (number of genes regulated) + +mean_ngenes <- mean(genes$ngenes) +# mean is 14.5 +# SEmean = s/sqrt(n) +SEmean <- sd(genes$ngenes)/(sqrt(length(genes$ngenes))) +# SEmean = 1.8324 + +#95% CI is mean + 2SE and mean - 2SE +mean_ngenes + (2*SEmean) +mean_ngenes - (2*SEmean) + +# 10.8352 < u < 18.1648 + +### b) #We can be 95% confident that the true mean is between 10.8352 and 18.1648 +``` + +```{r} +### Question 17 +# No, the interpretation is not correct. The first part of the statement that there is a 95% chance that the actual result is between 0.9 and 3.1 is correct. However, no further assumption (like it being higher or lower than the range values) can be made about the 5% chance it is not. +``` + +```{r} +### Question 18 +#number of carrion beetles that arive per night to flowers of species "Amorphophallus johnsonii" +beetles <- c(51, 45, 61, 76, 11, 117, 7, 132, 52, 149) + +### a) mean and sd +mean_beetles <- mean(beetles) +sd(beetles) +# mean = 70.1 +# standard deviation = 48.50074 + +### b) standard error of this estimate of the mean? +# SEmean = s/sqrt(n) +SEmean_beetles <- sd(beetles)/(sqrt(length(beetles))) + +### c) 95% CI of mean (provide lower and upper limits) +#lower limit (mean - 2*SE) +mean_beetles - (2*SEmean_beetles) +#lower limit = 39.42544 + +#upper limit (mean + 2*SE) +mean_beetles + (2*SEmean_beetles) +#upper limit = 100.7746 + +### d) The mean should be about the same regardless of sample size. + +### e) The standard deviation should also be about the same regardless of sample size. + +### f) The standard error of the mean for 25 data points would be less than the standard error of the mean for the 10 given data points. + + + +``` + +**2)** The other day, [Dave Curran](https://twitter.com/iamreddave) using some of the code from our lab made a wonderful animation of change in arctic sea ice. + +![](https://i.redd.it/9r9ook3d5xlx.gif) + +He used data from + +ftp://sidads.colorado.edu/DATASETS/NOAA/G02135/north/daily/data/NH_seaice_extent_final_v2.csv +ftp://sidads.colorado.edu/DATASETS/NOAA/G02135/north/daily/data/NH_seaice_extent_nrt_v2.csv + +I'm providing you with a cleaned form of his data (his code is [here](https://gist.github.com/cavedave/c5c2224c8c38661236c1c1ce894fd28f)) for you to work with in a few plots. The data file is called `NH_seaice_extent_monthly_1978_2016.csv` + +**2.1)** Load the data using `readr` and make the `Month_Names` column into a factor whose levels are in order of month. + +**2.2)** Make a boxplot showing the variability in sea ice extent every month. + +**2.3)** Use `dplyr` to get the annual minimum sea ice. Plot minimum ice by year, and add a trendline (either a smooth spline or a straight line). + +**2.4)** Plot sea ice by year, with different lines for different months. Then, add a new column (`mutate`!) using the ggplot2 function `cut_interval(Month, n=4)` - this will create four even bins. Seasons, if you will. Use `facet_wrap` on the same plot and split the plot into seasons. + +**2.5)** Last, make a line plot of sea ice by month. Gussy it up with colors by year, a different theme, and whatever other annotations, changes to axes, etc., you think best show the story of this data. + +**2.6 Extra Credit)** Make it animated. diff --git a/images/Rplot1.png b/images/Rplot1.png new file mode 100644 index 0000000..fdc56c5 Binary files /dev/null and b/images/Rplot1.png differ diff --git a/images/Rplot10.png b/images/Rplot10.png new file mode 100644 index 0000000..27cc3b1 Binary files /dev/null and b/images/Rplot10.png differ diff --git a/images/Rplot11.png b/images/Rplot11.png new file mode 100644 index 0000000..7107b71 Binary files /dev/null and b/images/Rplot11.png differ diff --git a/images/Rplot12.png b/images/Rplot12.png new file mode 100644 index 0000000..8a6c7fb Binary files /dev/null and b/images/Rplot12.png differ diff --git a/images/Rplot13.png b/images/Rplot13.png new file mode 100644 index 0000000..12c7e5e Binary files /dev/null and b/images/Rplot13.png differ diff --git a/images/Rplot14.png b/images/Rplot14.png new file mode 100644 index 0000000..e911422 Binary files /dev/null and b/images/Rplot14.png differ diff --git a/images/Rplot15.png b/images/Rplot15.png new file mode 100644 index 0000000..e052b82 Binary files /dev/null and b/images/Rplot15.png differ diff --git a/images/Rplot16.png b/images/Rplot16.png new file mode 100644 index 0000000..d4638fb Binary files /dev/null and b/images/Rplot16.png differ diff --git a/images/Rplot17.png b/images/Rplot17.png new file mode 100644 index 0000000..87b60ae Binary files /dev/null and b/images/Rplot17.png differ diff --git a/images/Rplot18.png b/images/Rplot18.png new file mode 100644 index 0000000..f101349 Binary files /dev/null and b/images/Rplot18.png differ diff --git a/images/Rplot19.png b/images/Rplot19.png new file mode 100644 index 0000000..736974e Binary files /dev/null and b/images/Rplot19.png differ diff --git a/images/Rplot2.png b/images/Rplot2.png new file mode 100644 index 0000000..cca22ca Binary files /dev/null and b/images/Rplot2.png differ diff --git a/images/Rplot20.png b/images/Rplot20.png new file mode 100644 index 0000000..caba959 Binary files /dev/null and b/images/Rplot20.png differ diff --git a/images/Rplot21.png b/images/Rplot21.png new file mode 100644 index 0000000..fee32ac Binary files /dev/null and b/images/Rplot21.png differ diff --git a/images/Rplot22.png b/images/Rplot22.png new file mode 100644 index 0000000..595ff82 Binary files /dev/null and b/images/Rplot22.png differ diff --git a/images/Rplot23.png b/images/Rplot23.png new file mode 100644 index 0000000..d2092e6 Binary files /dev/null and b/images/Rplot23.png differ diff --git a/images/Rplot24.png b/images/Rplot24.png new file mode 100644 index 0000000..983ce0f Binary files /dev/null and b/images/Rplot24.png differ diff --git a/images/Rplot25.png b/images/Rplot25.png new file mode 100644 index 0000000..d7efeee Binary files /dev/null and b/images/Rplot25.png differ diff --git a/images/Rplot26.png b/images/Rplot26.png new file mode 100644 index 0000000..5f61539 Binary files /dev/null and b/images/Rplot26.png differ diff --git a/images/Rplot27.png b/images/Rplot27.png new file mode 100644 index 0000000..1db7522 Binary files /dev/null and b/images/Rplot27.png differ diff --git a/images/Rplot28.png b/images/Rplot28.png new file mode 100644 index 0000000..7471582 Binary files /dev/null and b/images/Rplot28.png differ diff --git a/images/Rplot29.png b/images/Rplot29.png new file mode 100644 index 0000000..a015379 Binary files /dev/null and b/images/Rplot29.png differ diff --git a/images/Rplot3.png b/images/Rplot3.png new file mode 100644 index 0000000..749c032 Binary files /dev/null and b/images/Rplot3.png differ diff --git a/images/Rplot30.png b/images/Rplot30.png new file mode 100644 index 0000000..518e576 Binary files /dev/null and b/images/Rplot30.png differ diff --git a/images/Rplot31.png b/images/Rplot31.png new file mode 100644 index 0000000..0b18f2f Binary files /dev/null and b/images/Rplot31.png differ diff --git a/images/Rplot32.png b/images/Rplot32.png new file mode 100644 index 0000000..cf327b2 Binary files /dev/null and b/images/Rplot32.png differ diff --git a/images/Rplot33.png b/images/Rplot33.png new file mode 100644 index 0000000..57fdc9c Binary files /dev/null and b/images/Rplot33.png differ diff --git a/images/Rplot34.png b/images/Rplot34.png new file mode 100644 index 0000000..604d690 Binary files /dev/null and b/images/Rplot34.png differ diff --git a/images/Rplot35.png b/images/Rplot35.png new file mode 100644 index 0000000..0f471ab Binary files /dev/null and b/images/Rplot35.png differ diff --git a/images/Rplot4.png b/images/Rplot4.png new file mode 100644 index 0000000..b14827b Binary files /dev/null and b/images/Rplot4.png differ diff --git a/images/Rplot5.png b/images/Rplot5.png new file mode 100644 index 0000000..533db8a Binary files /dev/null and b/images/Rplot5.png differ diff --git a/images/Rplot6.png b/images/Rplot6.png new file mode 100644 index 0000000..23392a7 Binary files /dev/null and b/images/Rplot6.png differ diff --git a/images/Rplot7.png b/images/Rplot7.png new file mode 100644 index 0000000..ae9350e Binary files /dev/null and b/images/Rplot7.png differ diff --git a/images/Rplot8.png b/images/Rplot8.png new file mode 100644 index 0000000..a3939d6 Binary files /dev/null and b/images/Rplot8.png differ diff --git a/images/Rplot9.png b/images/Rplot9.png new file mode 100644 index 0000000..c44f49e Binary files /dev/null and b/images/Rplot9.png differ