Due Nov. 12 at Midnight.

Complete this activity in your R_package_lastname project.

Please have a look at this paper. It explains the relationship between air temperature, butterfly emergence, and plant flowering.

Phenology

Phenology is the study of when events happen in organisms' life cycles. For example, the first flowering of a plant for the year, or the emergence of forager bees. Typically, organisms take cues from their environment. Commonly, these are changes such as photoperiod (how much light there is per day) or temperature.

When organisms that rely on one another fall out of sync, it can be a problem. For example, if a plant starts to flower when the soil is warm enough, this will often occur after a period of warmer air temperatures because soil has a higher heat capacity than air. What happens to the bees when they emerge and don't find any food? This is called ecological mismatch. Originally described in 2004 by Winder and Schindler, ecological mismatch can mean that one or both species don't have their needs met by the environment.

What we're going to do today is look at some historical and present-day ecological data. What were the temperatures historically? And when did butterflies erupt from their cocoons? Butterflies need to be warm to incubate, exit the coccoon and go into flight.

Before trying the test, make sure you've read the Kharouba and Vellend paper and understand the hypotheses they were testing.

Project Two

Part One. 55 points.

download.file(url = "https://raw.githubusercontent.com/Paleantology/GBIO153H/master/data/Butterfly_data.csv", destfile = "data/Butterfly_data.csv")
download.file(url = "https://raw.githubusercontent.com/Paleantology/GBIO153H/master/data/Phenology_data.csv", destfile = "data/Phenology_data.csv")

Next, let's read in both the butterfly and phenology datasets. 5 pts.

butterfly_data <- read_csv("Data/Butterfly_data.csv")
butterfly_data
Phenology_data <- read_csv("Data/Phenology_data.csv")
Phenology_data

1) How many unique species of butterly are in the dataset? (5pts)

butterfly_data%>%
  count(ButterflySpecies)

2) Check out the relationship between temperature and time. First, let's plot it. Choose an approriate plot type, and plot the year vs. temperature. (5 pts)

title: "Project Two" output: html_document


Due Nov. 12 at Midnight.

Complete this activity in your R_package_lastname project.

Please have a look at this paper. It explains the relationship between air temperature, butterfly emergence, and plant flowering.

Phenology

Phenology is the study of when events happen in organisms' life cycles. For example, the first flowering of a plant for the year, or the emergence of forager bees. Typically, organisms take cues from their environment. Commonly, these are changes such as photoperiod (how much light there is per day) or temperature.

When organisms that rely on one another fall out of sync, it can be a problem. For example, if a plant starts to flower when the soil is warm enough, this will often occur after a period of warmer air temperatures because soil has a higher heat capacity than air. What happens to the bees when they emerge and don't find any food? This is called ecological mismatch. Originally described in 2004 by Winder and Schindler, ecological mismatch can mean that one or both species don't have their needs met by the environment.

What we're going to do today is look at some historical and present-day ecological data. What were the temperatures historically? And when did butterflies erupt from their cocoons? Butterflies need to be warm to incubate, exit the coccoon and go into flight.

Before trying the test, make sure you've read the Kharouba and Vellend paper and understand the hypotheses they were testing.

Project Two

Part One. 55 points.

download.file(url = "https://raw.githubusercontent.com/Paleantology/GBIO153H/master/data/Butterfly_data.csv", destfile = "data/Butterfly_data.csv")
download.file(url = "https://raw.githubusercontent.com/Paleantology/GBIO153H/master/data/Phenology_data.csv", destfile = "data/Phenology_data.csv")

Next, let's read in both the butterfly and phenology datasets. 5 pts.

butterfly_data <- read_csv("Data/Butterfly_data.csv")
butterfly_data
Phenology_data <- read_csv("Data/Phenology_data.csv")
Phenology_data

1) How many unique species of butterly are in the dataset? (5pts)

butterfly_data%>%
  count(ButterflySpecies)

2) Check out the relationship between temperature and time. First, let's plot it. Choose an approriate plot type, and plot the year vs. temperature. (5 pts)

ggplot(data = Phenology_data, mapping = aes(x = AnnualTemp, y = Year)) +
    geom_line()
  1. It looks like there might be a relationship between these two things. We'll check this with a linear regression. Use stat_smooth to add a regression to the plot. (5 pts)
ggplot(data = Phenology_data, mapping = aes(x = AnnualTemp, y = Year)) +
    geom_line()+
  stat_smooth()

Let's take a look at the actual butterflies.

4) If butterflies emerge based on temperature, what would we expect to be the relationship between Spring temperature and day of emergence? Summer temperature and day of emergence? Year and day? Test all three out below. Which predictor (day, spring temp, summer temp) you think is most relevant? (10 points)

ggplot(data = butterfly_data, mapping = aes(x = SpringTemp, y = Day)) +
    geom_point(aes(color = ButterflySpecies))+ stat_smooth() +ylim(0,365) +xlim(4,8) 
ggplot(data = butterfly_data, mapping = aes(x = Day, y = Year)) +
    geom_point(aes(color = ButterflySpecies))+ stat_smooth() +ylim(1931,2020) +xlim(100, 250)
ggplot(data = butterfly_data, mapping = aes(x = SummerTemp, y = Day)) +
    geom_point(aes(color = ButterflySpecies)) +stat_smooth() +ylim(0,365) +xlim(14.5,17)

I think the year and day is most relevant, for if the hypothesis is that there should be a phenological response to global warming, and that global warming can be predicted based on animal behavior, then this model shows that as global temperatures climb then the day of emergence should exhibit variabilty based on year.

5) Is there a significant linear relationship between any predictors and the response? (10 pts)

butterfly_model_fit <- lm(Day ~ Year, data = butterfly_data)
summary(butterfly_model_fit)
No, it doesn't appear so. Only 1.5% of the data can be explained by the relationship between year and day of emergence.

6) It looks like different animals might have different relationships to the predictor variables. Try plotting them out as a facets (5 pts).

ggplot(data = butterfly_data, mapping = aes(x = SummerTemp, y = Day)) +
    geom_line() +
    facet_wrap(facets = vars(ButterflySpecies))
ggplot(data = butterfly_data, mapping = aes(x = SpringTemp, y = Day)) +
    geom_line() +
    facet_wrap(facets = vars(ButterflySpecies))
ggplot(data = butterfly_data, mapping = aes(x = Year, y = Day)) +
    geom_line() +
    facet_wrap(facets = vars(ButterflySpecies))

7) Join our two datasets together and remake the facet plot above. Does this change your opinion of the relatedness of variables? (5 pts)

butterfly_data_joined <- Phenology_data %>% 
full_join(butterfly_data, by = c("Year"))
butterfly_data_joined
butterfly_data_joined_nona <- butterfly_data_joined%>%
  filter(!is.na(ButterflySpecies))
butterfly_data_joined_nona
ggplot(data = butterfly_data_joined_nona, mapping = aes(x = AnnualTemp, y = Day)) +
    geom_line() +
    facet_wrap(facets = vars(ButterflySpecies))

8) Wrap up: What is the relationship between temperature (remember that we looked at 3 kinds of temperature) and day of emergence? Is it the same for all species? How does this relate back to Kharouba and Vellend's hypotheses? (10 pts)

The day of emergence seems to be all over the place with most of the species, with both upward and downward directions in day of emergence but not necessarily early or later emergence patterns. This is not the same for all species, as S. melinus emerges later in a straight line as the temperature is climbing by year and by season; however, C. tullia, though variable, maintains a date of emergence between day 50 and 200 for nearly 100 years. Regarding the hypothesis, the steadfastness in timing of emergence for the butterflys does not correlate to climbing global temperatures causing phenological changes.

Part Two. 30 points.

For each of your function files, add to the .R:

Part Three. 15 points

Add, commit, and push this file to your R_Package_LastName GitHub repo. Place this file in vignettes. Place the data in data/. ```



awatt008/R_Package_Wattler documentation built on Dec. 19, 2021, 6:35 a.m.