Question 1

# odd and prime vectors 
odd <- c(1,3,5,7,9,11)

print(odd)
## [1]  1  3  5  7  9 11
prime <- c(2,3,5,7,11,13)

print(prime)
## [1]  2  3  5  7 11 13

Question 2

# moving vectors into the same data frame 
my_numbers <- c(odd, prime)

my_numbers
##  [1]  1  3  5  7  9 11  2  3  5  7 11 13
my_data <- data.frame(odd, prime)

my_data
##   odd prime
## 1   1     2
## 2   3     3
## 3   5     5
## 4   7     7
## 5   9    11
## 6  11    13
summary(my_data)
##       odd           prime       
##  Min.   : 1.0   Min.   : 2.000  
##  1st Qu.: 3.5   1st Qu.: 3.500  
##  Median : 6.0   Median : 6.000  
##  Mean   : 6.0   Mean   : 6.833  
##  3rd Qu.: 8.5   3rd Qu.:10.000  
##  Max.   :11.0   Max.   :13.000

Question 3

my_data
##   odd prime
## 1   1     2
## 2   3     3
## 3   5     5
## 4   7     7
## 5   9    11
## 6  11    13
diff <- prime - odd

diff
## [1] 1 0 0 0 2 2
my_data$odd <- as.factor(my_data$odd)

my_data$prime <- as.factor(my_data$prime)

my_data$new_column <- diff                # adding new column 'diff' to my data frame 

my_data$new_column <- as.factor(my_data$new_column)

my_data
##   odd prime new_column
## 1   1     2          1
## 2   3     3          0
## 3   5     5          0
## 4   7     7          0
## 5   9    11          2
## 6  11    13          2

Question 4 mean and variance of resistance

library(readr)
daphnia_resistance <- read_csv("daphnia_resistance.csv")
View(daphnia_resistance)

# load daphnia csv file

dr <- daphnia_resistance # re-naming

summary(dr)   # summary statistics 
##  cyandensity          resistance    
##  Length:32          Min.   :0.5600  
##  Class :character   1st Qu.:0.6775  
##  Mode  :character   Median :0.7600  
##                     Mean   :0.7509  
##                     3rd Qu.:0.8225  
##                     Max.   :0.9000
mean_resistance <- mean(dr$resistance)
var_resistance <- var(dr$resistance)

mean_resistance
## [1] 0.7509375
var_resistance
## [1] 0.009111996

Question 5

# plot developement rate over temp

library(readr)
aedes_development <- read_csv("aedes_development.csv")
View(aedes_development)

ad <- aedes_development

head(ad)
## # A tibble: 6 × 9
##   start.date end.date  temp sex     jar dev.time.days dev.rate weight.g
##   <chr>      <chr>    <dbl> <chr> <dbl>         <dbl>    <dbl>    <dbl>
## 1 2/21/2008  3/5/2008    22 F         2            13   0.0769   0.0037
## 2 2/21/2008  3/6/2008    22 F         2            14   0.0714  NA     
## 3 2/21/2008  3/3/2008    22 M         1            11   0.0909   0.0026
## 4 2/21/2008  3/3/2008    22 M         1            11   0.0909   0.002 
## 5 2/21/2008  3/3/2008    22 M         1            11   0.0909   0.0025
## 6 2/21/2008  3/3/2008    22 M         1            11   0.0909   0.0023
## # ℹ 1 more variable: weight.mg <dbl>
summary(ad) # summary statistics 
##   start.date          end.date              temp          sex           
##  Length:243         Length:243         Min.   : 5.0   Length:243        
##  Class :character   Class :character   1st Qu.: 9.0   Class :character  
##  Mode  :character   Mode  :character   Median :12.0   Mode  :character  
##                                        Mean   :12.9                     
##                                        3rd Qu.:16.0                     
##                                        Max.   :22.0                     
##                                                                         
##       jar        dev.time.days       dev.rate           weight.g       
##  Min.   :1.000   Min.   : 11.00   Min.   :0.006897   Min.   :0.001700  
##  1st Qu.:1.000   1st Qu.: 21.00   1st Qu.:0.017241   1st Qu.:0.002500  
##  Median :1.000   Median : 29.00   Median :0.034483   Median :0.002900  
##  Mean   :1.428   Mean   : 46.01   Mean   :0.035088   Mean   :0.003602  
##  3rd Qu.:2.000   3rd Qu.: 58.00   3rd Qu.:0.047619   3rd Qu.:0.004800  
##  Max.   :2.000   Max.   :145.00   Max.   :0.090909   Max.   :0.005900  
##                                                      NA's   :20        
##    weight.mg    
##  Min.   :1.700  
##  1st Qu.:2.500  
##  Median :2.900  
##  Mean   :3.602  
##  3rd Qu.:4.800  
##  Max.   :5.900  
##  NA's   :20
library(ggplot2)       # plotting dev.rate over temp as p1

p1 <- ggplot(ad, aes(x = dev.rate, y = temp)) + 
  geom_point(aes(color = dev.rate)) + 
  geom_smooth(method = lm, color = "black", fill = "red", alpha = 0.3) +
  labs(title = "Development Rate Over Temperature", x = "Development Rate", y = "Temperature") + 
  theme_minimal() + theme(plot.title = element_text(face = "bold"), 
                          axis.title.x = element_text(face = "bold"), 
                          axis.title.y = element_text(face = "bold"))


p1

                                          # note: calculating mean and variance of dev.rate and weight.mg (use 'na,rm = TRUE') 

summary(ad)
##   start.date          end.date              temp          sex           
##  Length:243         Length:243         Min.   : 5.0   Length:243        
##  Class :character   Class :character   1st Qu.: 9.0   Class :character  
##  Mode  :character   Mode  :character   Median :12.0   Mode  :character  
##                                        Mean   :12.9                     
##                                        3rd Qu.:16.0                     
##                                        Max.   :22.0                     
##                                                                         
##       jar        dev.time.days       dev.rate           weight.g       
##  Min.   :1.000   Min.   : 11.00   Min.   :0.006897   Min.   :0.001700  
##  1st Qu.:1.000   1st Qu.: 21.00   1st Qu.:0.017241   1st Qu.:0.002500  
##  Median :1.000   Median : 29.00   Median :0.034483   Median :0.002900  
##  Mean   :1.428   Mean   : 46.01   Mean   :0.035088   Mean   :0.003602  
##  3rd Qu.:2.000   3rd Qu.: 58.00   3rd Qu.:0.047619   3rd Qu.:0.004800  
##  Max.   :2.000   Max.   :145.00   Max.   :0.090909   Max.   :0.005900  
##                                                      NA's   :20        
##    weight.mg    
##  Min.   :1.700  
##  1st Qu.:2.500  
##  Median :2.900  
##  Mean   :3.602  
##  3rd Qu.:4.800  
##  Max.   :5.900  
##  NA's   :20
mean_dev.rate <- mean(ad$dev.rate, na.rm = TRUE)
var_dev.rate <- mean(ad$dev.rate, na.rm = TRUE) 

mean_weight.mg <- mean(ad$weight.mg, na.rm = TRUE)
var_weight.mg <- mean(ad$weight.mg, na.rm = TRUE) 


# plot pupal rate in mg over temp

mean_dev.rate
## [1] 0.03508771
var_dev.rate
## [1] 0.03508771
mean_weight.mg
## [1] 3.602242
var_weight.mg
## [1] 3.602242
        # plotting pupal weight in mg over temp

head(ad)
## # A tibble: 6 × 9
##   start.date end.date  temp sex     jar dev.time.days dev.rate weight.g
##   <chr>      <chr>    <dbl> <chr> <dbl>         <dbl>    <dbl>    <dbl>
## 1 2/21/2008  3/5/2008    22 F         2            13   0.0769   0.0037
## 2 2/21/2008  3/6/2008    22 F         2            14   0.0714  NA     
## 3 2/21/2008  3/3/2008    22 M         1            11   0.0909   0.0026
## 4 2/21/2008  3/3/2008    22 M         1            11   0.0909   0.002 
## 5 2/21/2008  3/3/2008    22 M         1            11   0.0909   0.0025
## 6 2/21/2008  3/3/2008    22 M         1            11   0.0909   0.0023
## # ℹ 1 more variable: weight.mg <dbl>
p2 <- ggplot(ad, aes(x = weight.mg, y = temp, fill = weight.mg)) +
       geom_col() + 
         labs(title = "Pupal Weight by Temperature", 
              x = "Weight (mg)", 
              y = "Temperature") + 
         theme_minimal() + theme(plot.title = element_text(face = "bold"), 
                                 axis.title.x = element_text(face = "bold"), 
                                 axis.title.y = element_text(face = "bold"))
       
p2

library(cowplot)     #plot_grid()

mp <- plot_grid( 
  p1 + theme(plot.title = element_blank(), axis.title.x = element_blank(), axis.title.y = element_blank()), 
  p2 + theme(plot.title = element_blank(), axis.title.x = element_blank(), axis.title.y = element_blank()))

mp

Interpretation of The Two Figures of Question 5

What do the figures show you about the biology of development in these mosquitoes?

the mosquitoes which are exposed to higher temperatures have a greater development rate compared to the mosquitoes exposed to lower temperatures.

Does anything look ‘weird’?

in terms of weight, there seems to be a drop off around 3-4mg. There seems to be a correlation between greater mass and lower temperature and vice-versa.

Does the data ‘make sense’?

Figure 1 shows that there is a correlation between higher temperatures and faster development rates of mosquitoes. Knowing that mosquitoes thrive and are more active in hotter environments this would be expected and does make sense. Figure 2 shows more mosquitoes as a lighter weight in high temperatures than heavier mosquitoes. Maybe heavier mosquitoes have a harder time regulating body functions in harsher environments? Or once a mosquito matures, they move to lower temperatures.