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
89 changes: 89 additions & 0 deletions Babson_03.Rmd
Original file line number Diff line number Diff line change
@@ -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.
Binary file added images/Rplot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot29.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot31.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rplot32.png
Binary file added images/Rplot33.png
Binary file added images/Rplot34.png
Binary file added images/Rplot35.png
Binary file added images/Rplot4.png
Binary file added images/Rplot5.png
Binary file added images/Rplot6.png
Binary file added images/Rplot7.png
Binary file added images/Rplot8.png
Binary file added images/Rplot9.png