#read data
data <- read.csv("Data_time.csv")
data$Time <- as.numeric(data$Time)
data$Cat <- as.character(data$Cat)
data$Cat2 <- as.character(data$Cat2)
#detections of python and other snakes
table (data$Cat)
#detections of large snakes
table (data$Cat2)
# By treatment and control
table (data$treat)
head (data)
#libraries we may use
library(tidyverse)
library(ggpubr)
library (glmmTMB)
library(data.table)
library("plotrix")
library(DHARMa)
library(sjPlot)
library(sjmisc)
library(sjlabelled)
#subset - note that names have a space after them
other <- data[which(data$Cat=="Other "),]
pyt <- data[which(data$Cat=="Python "),]
pyt_T <- pyt %>%
filter(treat == "trt")
#summerize pythons at treatment pens
median (pyt_T$Time/60)
# test time at pens for other snakes, first plot
hist (other$Time)
#non normal use wilcox to text if treatment and control vary for time other snakes spent at pens
res <- wilcox.test(Time ~ treat, data = other,
exact = FALSE)
res
### subset for large snakes
large <- data[which(data$Cat2=="Large"),]
## summary stats of other snakes at treatment and other pens
Large_T <- large %>%
filter(treat == "trt")
Large_C <- large %>%
filter(treat == "ctrl")
median (Large_T$Time/60)
median (Large_C$Time/60)
## summary stats of Large snakes at treatment and other pens
other_T <- other %>%
filter(treat == "trt")
other_C <- other %>%
filter(treat == "ctrl")
median (other_T$Time/60)
median (other_C$Time/60)
# test time at pens for large snakes, first plot
hist (large$Time)
#non normal use wilcox to text if treatment and control vary for time other snakes spent at pens
res2 <- wilcox.test(Time ~ treat, data = large,
exact = FALSE)
res2
# Compare other snakes between treatments. Load data
snakes3 <-read.csv("snakes3.csv",header = TRUE)
#Count data use a poisson model for other snakes and large snakes
Others_glmm <-glmmTMB(S ~ Treatment + (1|Pair), family=poisson, data=snakes3)
summary(Others_glmm)
Large_glmm <-glmmTMB(L ~ Treatment + (1|Pair), family=poisson, data=snakes3)
summary(Large_glmm)
#Incidence Rate Ratios
tab_model(Others_glmm)
tab_model(Large_glmm)
#plot residuals to check model fit
others_glmm_simres<-simulateResiduals(Others_glmm)
plot(others_glmm_simres)
Large_glmm_simres<-simulateResiduals(Large_glmm)
plot(Large_glmm_simres)
#chi square pythons to test treatment and control of pythons
chisq.test(x = table(pyt$treat))
# Histogram
dat = read_csv("timestamp.csv")
dat$hours = as.numeric(dat$Time)/(60*60)
library (ggtext)
library (ggplot2)
ggplot(dat) +
geom_histogram(aes(x = hours),
bins = 24,
boundary = 0,
color = "white") +
scale_x_continuous(name = "Time (hours)",
breaks = c(seq(0, 24, 4)),
labels = paste0(c(seq(0, 24, 4)), ":00")) +
ylab("Pictures") +
theme_bw() +
theme(panel.grid = element_blank(),
axis.text = element_text(size = 18),
axis.title = element_text(size = 24)) +
geom_vline(xintercept = 7, linetype = 2) +
geom_vline(xintercept = 15, linetype = 2) +
labs(x='Time of day (hours)', y = 'Number of photos')+
geom_curve(aes(x = 7, y = 230,
xend = 9, yend = 250), curvature = -0.2, colour = "grey25") +
geom_curve(aes(x = 13, y = 250,
xend = 15, yend = 230), curvature = -0.2, colour = "grey25") +
annotate("richtext", x = 11, y = 250, hjust = 0.5, lineheight = 0.85,size = 4,
colour = "grey25",
label = "Timespan of
visual sampling",
label.padding = grid::unit(rep(0, 4), "pt"),
fill = NA, label.color = NA)+
geom_vline(xintercept = 18, linetype = 3) +
geom_vline(xintercept = 20.25, linetype = 3) +
geom_curve(aes(x = 18, y = 230,
xend = 18.5, yend = 250), curvature = -0.2, colour = "grey25") +
geom_curve(aes(x = 19.75, y = 250,
xend = 20.25, yend = 230), curvature = -0.2, colour = "grey25") +
annotate("richtext", x = 19.125, y = 250, hjust = 0.5, lineheight = 0.85, size = 4,
colour = "grey25",
label = "Timespan of
canine
sampling",
label.padding = grid::unit(rep(0, 4), "pt"),
fill = NA, label.color = NA)
ggsave("Histogram.png")