Code for Paper 2

underpass <- read.csv("underpass.csv") 
underpassdaily <- read.csv("underpassdaily.csv")
library(tidyverse)
library(ggplot2)
library(ggthemes) 
library(knitr)
library(tibble)
library(tidyr)
mod1 <- lm(fpfreq~length, data = underpass)
summary(mod1)
ggplot(underpass, aes(x = length, y = fpfreq)) + 
geom_point(colour = "navy", alpha = .3) + 
geom_smooth(colour = "navy", method = "lm", se = FALSE) +
labs(x = "Length of underpass (m)", y = "Frequency of full passage") 
ggsave ("FP length.png")
mod2 <- lm(fpfreq~waterprox, data = underpass)
summary(mod2)
ggplot(underpass, aes(x = waterprox, y = fpfreq)) + 
geom_point(colour = "navy", alpha = .3) + 
geom_smooth(colour = "navy", method = "lm", se = FALSE) +
labs(x = "Proximity to watercourse/body (m)", y = "Frequency of full passage") 
ggsave ("FP water.png")
mod3 <- lm(fpfreq~woodlandprox, data = underpass)
summary(mod3)
ggplot(underpass, aes(x = woodlandprox, y = fpfreq)) + 
geom_point(colour = "navy", alpha = .3) + 
geom_smooth(colour = "navy", method = "lm", se = FALSE) +
labs(x = "Proximity to woodland (m)", y = "Frequency of full passage")
ggsave ("FP woodland.png")
mod4 <- lm(fpfreq~urbanprox, data = underpass)
summary(mod4)
ggplot(underpass, aes(x = urbanprox, y = fpfreq)) + 
geom_point(colour = "navy", alpha = .3) + 
geom_smooth(colour = "navy", method = "lm", se = FALSE) +
labs(x = "Proximity to urban area (m)", y = "Frequency of full passage")
ggsave ("FP urban.png")
ggplot(underpass, aes(x = type, y = fpfreq, colour = type)) + 
  geom_boxplot() +
  geom_jitter(alpha = 0.3) +
  scale_colour_manual(values = c(
    "Amphibian" = "gold",
    "Badger" = "navy")) +
  labs(x = "Type of underpass", y = "Frequency of full passage") +
  theme(legend.position = "none")
  ggsave ("FP underpass type.png")
t.test(fpfreq ~ type, data = underpass) 
ggplot(underpass, aes(x = road, y = fpfreq, colour = road)) + 
  geom_boxplot() +
  geom_jitter(alpha = 0.3) +
  scale_colour_manual(values = c(
    "Layby" = "gold",
    "Single carriageway" = "navy"
  )) +
  labs(x = "Type of road", y = "Frequency of full passage") +
  theme(legend.position = "none")
ggsave ("FP road type.png")
t.test(fpfreq ~ road, data = underpass) 
data <- data.frame(
  Group = rep(c("AT1", "AT2", "BT1", "BT2", "BT3" ), each = 2),
  Activity = rep(c("Full passage", "Presence"), times = 5),
  Value = c(5, 6, 8, 5, 4, 4, 8, 8, 5, 7)
)

ggplot(data, aes(x = Group, y = Value, fill = Activity)) +
  geom_bar(stat = "identity", position = "dodge") +
  (scale_fill_viridis_d(option = "E")) + scale_y_continuous(limits = c(0, 9), breaks = 0:9) +
  labs(x = "Underpass reference",
    y = "Number of days",
    fill = NULL
  ) +
  theme(legend.position = "top", plot.title = element_text(hjust = 0.5))
ggsave ("Overall activity.png")
data <- data.frame(
  Group = rep(c("AT1", "AT2", "BT1", "BT2", "BT3" ), each = 2),
  Activity = rep(c("Full passage", "Presence"), times = 5),
  Value = c(2, 3, 6, 3, 1, 0, 8, 3, 3, 6)
)

ggplot(data, aes(x = Group, y = Value, fill = Activity)) +
  geom_bar(stat = "identity", position = "dodge") +
  (scale_fill_viridis_d(option = "E")) + scale_y_continuous(limits = c(0, 9), breaks = 0:9) +
  labs(x = "Underpass reference",
    y = "Number of days",
    fill = NULL
  ) +
theme(legend.position = "top", plot.title = element_text(hjust = 0.5)) 
ggsave ("Badger activity.png")
data <- data.frame(
  Group = rep(c("AT1", "AT2", "BT1", "BT2", "BT3" ), each = 2),
  Activity = rep(c("Full passage", "Presence"), times = 5),
  Value = c(3, 4, 8, 3, 3, 4, 1, 7, 4, 3)
)

ggplot(data, aes(x = Group, y = Value, fill = Activity)) +
  geom_bar(stat = "identity", position = "dodge") +
  (scale_fill_viridis_d(option = "E")) + scale_y_continuous(limits = c(0, 9), breaks = 0:9) +
  labs(
        x = "Underpass reference",
    y = "Number of days",
    fill = NULL
  ) +
theme(legend.position = "top", plot.title = element_text(hjust = 0.5))
ggsave ("Fox activity.png")
data <- data.frame(
  Group = rep(c("AT1", "AT2", "BT1", "BT2", "BT3" ), each = 2),
  Activity = rep(c("Full passage", "Presence"), times = 5),
  Value = c(0, 2, 0, 0, 0, 0, 0, 2, 0, 0)
)

ggplot(data, aes(x = Group, y = Value, fill = Activity)) +
  geom_bar(stat = "identity", position = "dodge") +
  (scale_fill_viridis_d(option = "E")) + scale_y_continuous(limits = c(0, 9), breaks = 0:9) +
  labs(
        x = "Underpass reference",
    y = "Number of days",
    fill = NULL
  ) +
theme(legend.position = "top", plot.title = element_text(hjust = 0.5))
ggsave ("Bird activity.png")
mod5 <-lm(fpfreq ~ length + waterprox + woodlandprox + urbanprox, data = underpass)
summary(mod5)
mod6 <-lm(bfreq ~ length, data = underpass)
summary(mod6)
mod7 <-lm(bfreq ~ waterprox, data = underpass)
summary(mod7)
mod8 <-lm(bfreq ~ woodlandprox, data = underpass)
summary(mod8)
mod9 <-lm(bfreq ~ urbanprox, data = underpass)
summary(mod9)
mod10 <-lm(bfreq ~ length + waterprox + woodlandprox + urbanprox, data = underpass)
summary(mod10)
mod11 <-lm(ffreq ~ length, data = underpass)
summary(mod11)
mod13 <-lm(ffreq ~ waterprox, data = underpass)
summary(mod13)
mod14 <-lm(ffreq ~ woodlandprox, data = underpass)
summary(mod14)
mod15 <-lm(ffreq ~ urbanprox, data = underpass)
summary(mod15)
mod15 <-lm(ffreq ~ length + waterprox + woodlandprox + urbanprox, data = underpass)
summary(mod15)
temperature_data <- data.frame(
  Survey_Day = 1:9,
  Min_Temp = c(13, 13, 12, 14, 15, 15, 11, 14, 17),
  Max_Temp = c(25, 26, 28, 30, 30, 28, 21, 25, 25)
)

long_temp_data <- pivot_longer(
  temperature_data,
  cols = c(Min_Temp, Max_Temp),
  names_to = "Type",
  values_to = "Temperature"
)

ggplot(long_temp_data, aes(x = Survey_Day, y = Temperature, color = Type)) +
  geom_line(size = 1.2) +
  geom_point(size = 2) +
  scale_color_manual(values = c("Min_Temp" = "navy", "Max_Temp" = "gold")) +
  scale_x_continuous(breaks = 1:9) +
  labs(
    x = "Survey Day",
    y = "Temperature (°C)",
    color = "Temperature Type"
  ) +
  theme(legend.position = "none")
ggsave("Temp.png")
ggplot(underpass, aes(x = type, y = bfreq, colour = type)) + 
  geom_boxplot() +
  geom_jitter(alpha = 0.3) +
  scale_colour_manual(values = c(
    "Amphibian" = "gold",
    "Badger" = "navy")) +
  labs(x = "Type of underpass", y = "Frequency of full passage") +
  theme(legend.position = "none")
  ggsave ("B underpass type.png") #Badger freq
t.test(bfreq ~ type, data = underpass) 
ggplot(underpass, aes(x = type, y = ffreq, colour = type)) + 
  geom_boxplot() +
  geom_jitter(alpha = 0.3) +
  scale_colour_manual(values = c(
    "Amphibian" = "gold",
    "Badger" = "navy")) +
  labs(x = "Type of underpass", y = "Frequency of full passage") +
  theme(legend.position = "none")
  ggsave ("F underpass type.png") #Fox freq
t.test(ffreq ~ type, data = underpass)