# library(reshape)
# library(ggplot2)
# library(dplyr)
# library(yarrr)
# source('./fncs/21_patch_statistics.R')
Dataset including the patch size for every location of roe and red deer location dataset.
# ce <- read.csv2('../data/2_patchsize/red.csv',dec = ',')
# ca <- read.csv2('../data/2_patchsize/roe.csv',dec = ',')
# head(ce)
# head(ca)
# # CALCULATE NUMBER OF PATCHES AND NUMBER OF FIXES IN A PATCH SMALLER THAN 25 HECTARE
# patch_ce_l <- patch_statistics(ce, patchsize = 250000)
# patch_ca_l <- patch_statistics(ca, patchsize = 250000)
First, we calculated the number of patches per individual. Then we sum up all the patches over all populations per species.
# # NR OF PATCHES
# patch_nr_ce <- patch_ce_l[[1]]
# patch_nr_ce$species <- 'red'
# patch_nr_ca <- patch_ca_l[[1]]
# patch_nr_ca$species <- 'roe'
#
# patch_nr <- rbind(patch_nr_ce,patch_nr_ca)
# patch_nr <- melt(patch_nr, id=c("species","animals_id"))
#
# # STATISTICS ABOUT NR OF PATCHES PER INDIVIDUAL OVER ALL POPULATIONS PER SPECIES
# (r <- group_by(patch_nr, species, variable) %>%
# summarise(sum = sum(value),
# mean= mean(value),
# median=median(value),
# max=max(value),
# min=min(value)))
# barplot(r$sum,
# cex.names=0.6,
# names.arg=c(paste0(r$species, ' ' , r$variable)),
# main='total number of patches over all population')
First, we calculated the proportion of fixes that is in a patch smaller than 25 hectare, for each individual. Then, we calculate the mean of that proportion over all populations (and thus all individuals)
# patch_fx_ce <- patch_ce_l[[2]]
# patch_fx_ce$species <- 'red'
# patch_fx_ca <- patch_ca_l[[2]]
# patch_fx_ca$species <- 'roe'
#
# patch_fx <- rbind(patch_fx_ce,patch_fx_ca)
# (r <- group_by(patch_fx, species, variable) %>%
# summarise(mean= mean(Freq),
# median=median(Freq),
# max=max(Freq),
# min=min(Freq)))
# barplot(r$mean,
# cex.names=0.6,
# names.arg=c(paste0(r$species, ' ', r$variable)),
# main='mean proportion of fixes in small patches (<25ha) per individual over all populations')
# #boxplot(Freq ~ species + variable, data=patch_fx, cex.axis=0.6, main='proportion of fixes in small patches (<25 ha) per individual')
# pirateplot(Freq ~ variable + species, data=patch_fx, cex.axis=0.6, main='proportion of fixes in small patches (<25 ha) per individual')