##################################################### # Marco FW Gauger # 2021/08/23 # # This is the script to obtain tab S 2 of supplemental material of the manuscript submitted to PeerJ Gauger et al 2021 Diel influences on bottlenose dolphin acoustic detection in a coastal lagoon in the southwestern Gulf of California ##################################################### ifelse("mgcv" %in% rownames(installed.packages()) == FALSE, install.packages("mgcv", dependencies = T), ("mgcv is already installed")) ifelse("broom" %in% rownames(installed.packages()) == FALSE, install.packages("broom", dependencies = T), ("broom is already installed")) require(mgcv) require(broom) Sys.setlocale("LC_ALL","English") #Sys.setenv(TZ='UTC') analysed_data_hour <- read.csv("Supplemental Data S1.csv", sep=";") analysed_data_hour$cluster_hcpc <- as.factor(analysed_data_hour$cluster_hcpc) dp10m_mod_cluster_I_h <- gam(dp10m_ELAP1~ s(lunar_phase, bs="cc") + te(derivate_tide, tide, bs=c("tp","tp"), k=c(10,10)) + s(SST, k=10, bs="tp") + s(h, by= cluster_hcpc, bs="cc") + effort + s(depth, k=4) + s(distance_BLAP, k=4)+ s(cluster_hcpc, bs="re"), data=analysed_data_hour, method="REML",family="poisson", knots=list(h = c(0,24))) table1 <- as.data.frame(cbind(cbind(unlist(summary(dp10m_mod_cluster_I_h)[c(1)])),cbind(unlist(summary(dp10m_mod_cluster_I_h)[c(2)])[1:2]),cbind(unlist(summary(dp10m_mod_cluster_I_h)[c(3)])),cbind(unlist(summary(dp10m_mod_cluster_I_h)[c(4)])))) table2 <- as.data.frame(tidy(dp10m_mod_cluster_I_h)) table <- as.data.frame(cbind(c("coefficients","intercept","effort","smooth",table2[,1]), rbind(c("estimation", "error est.", "t", "p") , rbind(formatC(as.matrix(table1), format="fg",digits=3), c("edf", "Redf", "ChiČ", "p"), formatC(as.matrix(table2[,2:5]), format="fg",digits=3))))) colnames(table) <- rep("", 5) table$significance <- as.character(rep("", nrow(table))) table$significance[as.character(table[,5]) < 0.05] <- "*" table$significance[as.character(table[,5]) < 0.01] <- "**" table$significance[as.character(table[,5]) < 0.001] <- "***" table$significance[table[,5] =="p"] <- "significance" row.names(table) <- table[,1] colnames(table) <- "" (table <- table[,2:6]) write.csv(table, "clipboard", sep=";")