knitr::opts_chunk$set(echo = TRUE)
This script create the site persistence parts tables 5 and 6 It uses a dataset where Mencia and Aceitillar data have been combined.
library(reshape2) library(here)
Load annual Captures data with Mencia AND Aceitillar combined
filename <- "site_persist.RData" load(here::here("data",filename)) ls()
focal.mig <- c("OVEN","BAWW","COYE","AMRE","CMWA", "BTBW","PAWA","PRAW") focal.res <- c("HILC" # formerly HLCU ,"STOF" ,"RLTH" ,"NOMO" ,"GTGT" # formerly GRWA ,"BANA" ,"BCPT" ,"YFGR" ,"BFGR" ,"GABU") focals <- c(focal.mig,focal.res)
i.focal <- which(site_persist$spp.code %in% focals) site_persist.foc <- site_persist[i.focal,]
replicate order from tables in oridingal MS
site_persist.foc$spp.code <- factor(site_persist.foc$spp.code, levels = focals)
site_persist.foc$site <- factor(site_persist.foc$site, levels = c("La Cueva", "La Caoba", "Morelia", "El Corral", "Aceitillar"))
#sample size sp.cast.n <- dcast(data= site_persist.foc[,], formula = spp.code + stat ~ site, value.var = "site", fun.aggregate = length) #siter persisten individuals sp.cast.persist <- dcast(data= site_persist.foc[,], formula = spp.code + stat ~ site+persist, value.var = "site", fun.aggregate = length)
#isolate focal columns j <- grep("_P",names(sp.cast.persist)) sp.cast.persist[,j] sp.cast.persist2 <- round(sp.cast.persist[,j]/sp.cast.n[,-c(1:2)],2)
sp.cast.persist3 <- sp.cast.persist2 sp.cast.persist3$`La Cueva_P` <- paste(sp.cast.persist3$`La Cueva_P`," (",sp.cast.n$`La Cueva`,")", sep = "") sp.cast.persist3$`La Caoba_P` <- paste(sp.cast.persist3$`La Caoba_P`," (",sp.cast.n$`La Caoba`,")", sep = "") sp.cast.persist3$Morelia_P <- paste(sp.cast.persist3$`Morelia_P`," (",sp.cast.n$Morelia,")", sep = "") sp.cast.persist3$`El Corral_P` <- paste(sp.cast.persist3$`El Corral_P`," (",sp.cast.n$`El Corral`,")", sep = "")
table5_6_site_persist <- data.frame(spp.code = sp.cast.persist[,1], sp.cast.persist3)
write.csv(table5_6_site_persist, file = "./tables/temp_tables_5_6_site_persist.csv", row.names = F)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.