knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 4 )
library(alohakez) library(tidyverse)
head(cce_seabird) tail(cce_seabird) cce_seabird$year <- as.integer(cce_seabird$year) unique(cce_seabird$season) cce_seabird$season <- factor(cce_seabird$season, levels = c("fall", "wint", "sprg", "summ")) cce_seabird %>% head()
cce_seabird %>% group_by(year) %>% count() cce_seabird %>% group_by(season) %>% count()
annual_seabird <- cce_seabird %>% group_by(year) %>% summarise(avg_density=mean(bird_density), avg_richness=mean(bird_richness))
cce_seabird %>% ggplot(aes(x=year)) + geom_line(aes(y=bird_density, color=season), size=1) + geom_line(aes(y=avg_density), data=annual_seabird, color="black", size=0.8, linetype="dotdash") + labs( x= "Year", y = "Bird Density", title = "Seasonal Seabird Density in 1987 - 2006") cce_seabird %>% ggplot(aes(x=year)) + geom_line(aes(y=bird_richness, color=season), size=1) + geom_line(aes(y=avg_richness), data=annual_seabird, size=0.8, linetype="dotdash") + labs( x= "Year", y = "Bird Richness", title = "Seasonal Seabird Richness in 1987 - 2006")
cce_seabird %>% ggplot(aes(x=year)) + geom_line(aes(y=bird_density, color=season), size=1) + geom_line(aes(y=avg_density), data=annual_seabird, color="black", size=0.8, linetype="dotdash") + labs( x= "Year", y = "Bird Density", title = "Seasonal Seabird Density in 1987 - 2006") + facet_wrap(~season) cce_seabird %>% ggplot(aes(x=year)) + geom_line(aes(y=bird_richness, color=season), size=1) + geom_line(aes(y=avg_richness), data=annual_seabird, size=0.8, linetype="dotdash") + labs( x= "Year", y = "Bird Richness", title = "Seasonal Seabird Richness in 1987 - 2006") + facet_wrap(~season)
cce_seabird %>% group_by(season) %>% summarise(avg_density=mean(bird_density), avg_richness=mean(bird_richness))
seabird <- left_join(cce_seabird, annual_seabird) head(seabird) seabird <- seabird %>% mutate(diff_density=bird_density-avg_density, diff_richness=bird_richness-avg_richness) head(seabird)
seabird %>% ggplot(aes(x=year)) + geom_point(aes(y=diff_density, color=season)) + geom_hline(yintercept=0, linetype="longdash") + labs( x= "Year") + facet_wrap(~season) seabird %>% ggplot(aes(x=year)) + geom_point(aes(y=diff_richness, color=season)) + geom_hline(yintercept=0, linetype="longdash") + labs( x= "Year") + facet_wrap(~season)
spring seems to have higher bird density and richness
cce_seabird %>% ggplot(aes(x=bird_density, y=bird_richness)) + geom_point(aes(color=season)) + geom_point(aes(x=avg_density, y=avg_richness), alpha=0.6, shape=15, data=annual_seabird) + labs(x = "Bird Density", y = "Bird Richness", title = "Bird Density vs Bird Richness") cce_seabird %>% ggplot(aes(x=bird_density, y=bird_richness)) + geom_point(aes(color=season)) + #geom_point(aes(x=avg_density, y=avg_richness), alpha=0.6, shape=15, data=annual_seabird) + labs(x = "Bird Density", y = "Bird Richness", title = "Bird Density vs Bird Richness") + facet_wrap(~season)
more density means more richness \ makes sense
cce_sst <- cce_sst %>% filter(sea_surface_temperature_flag==0) %>% filter(!is.na(sea_surface_temperature_c)) %>% filter(year>=1980) #save computing cce_sst <- cce_sst %>% mutate(month_day=as.Date(paste(2224, month, day, sep = "/" )))
fall_start <- as.Date("2224/09/22") wint_start <- as.Date("2224/12/21") sprg_start <- as.Date("2224/3/20") summ_start <- as.Date("2224/6/20") cce_sst <- cce_sst %>% mutate( season = case_when( month_day>=fall_start & month_day<wint_start ~ "fall", month_day>=wint_start | month_day<sprg_start ~ "wint", month_day>=sprg_start & month_day<summ_start ~ "sprg", month_day>=summ_start & month_day<fall_start ~ "summ" ) ) cce_sst$season <- factor(cce_sst$season, levels = c("fall", "wint", "sprg", "summ")) levels(cce_sst$season)[2:3] #cce_sst %>% select(date_pst:day, month_day, season)
annual_sst<- cce_sst %>% group_by(year) %>% summarize(annual_temp = mean(sea_surface_temperature_c)) annual_sst %>% head() seasonal_sst <- cce_sst %>% group_by(year, season) %>% summarize(seasonal_temp = mean(sea_surface_temperature_c)) seasonal_sst <- left_join(seasonal_sst, annual_sst)
bird_sst <- left_join(seabird, seasonal_sst) %>% arrange(year, season) bird_sst %>% select(year, season, seasonal_temp, annual_temp)
bird_sst %>% ggplot(aes(x=year)) + geom_path(aes(y=seasonal_temp, color=season), size=1) + geom_path(aes(y=annual_temp)) + theme_minimal() + labs(x = "Year", y = "Seasonal Sea-Surface Temperature (C)")
bird_sst %>% ggplot(aes(x=year)) + geom_path(aes(y=annual_temp), color="blue") + geom_path(aes(y=avg_density)) + geom_path(aes(y=avg_richness)) + scale_x_continuous(breaks = scales::pretty_breaks(n = 10))
bird_sst %>% ggplot() + geom_point(aes(x=bird_density, y= seasonal_temp, color=season)) + geom_point(aes(x=avg_density, y=annual_temp), alpha=0.6, shape=15, size=1) bird_sst %>% ggplot() + geom_point(aes(x=bird_density, y= seasonal_temp, color=season)) + geom_point(aes(x=avg_density, y=annual_temp), alpha=0.6, shape=15, size=1) + facet_wrap(~season)
bird_sst %>% ggplot() + geom_point(aes(x=bird_richness, y= seasonal_temp, color=season)) + geom_point(aes(x=avg_richness, y=annual_temp), alpha=0.6, shape=15)
we see lower bird richness happens when temperature is lower than 18
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.