knitr::opts_chunk$set(echo = TRUE) library(MetaLandSim) library(plyr) library(dplyr) library(ggplot2) library(pander) library(RMark)
# Loading all population data # Output from IBM model df.pop <- read.csv2("c:/temp/output.txt", sep = ",") str(df.pop) summary(df.pop)
Number of patches: r dplyr::n_distinct(df.pop$patch)
Number of timesteps: r dplyr::n_distinct(df.pop$timestep)
Number of unique individuals: r dplyr::n_distinct(df.pop$ID)
Constant detection probability (i.e. not dependent on time, density, patch, ...)
other assumptions...
p <- 0.8 # Detection probability EncTime <- c(20,21,22,23,24,25,26,27,28,29) # Encounter timesteps
Detection probability r p
Encounter timesteps r EncTime
df.EncHistFlat <- data.frame() for (i in EncTime) { df.mark <- df.pop %>% dplyr::filter(timestep == i, age > 1) %>% dplyr::sample_frac(p, replace = FALSE) %>% select(timestep, ID) df.mark$Occ <- 1 df.EncHistFlat <- rbind(df.EncHistFlat, df.mark) } str(df.EncHistFlat) df.EncHist <- df.EncHistFlat %>% tidyr::spread(timestep, Occ, fill = 0) %>% tidyr::unite(ch, 1:length(EncTime) + 1, sep = "") %>% dplyr::select(ch) df.EncHist CJS.Phidot.pdot <- mark(data = df.EncHist)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.