knitr::opts_chunk$set(echo = TRUE)
library(reshape2)

Load site persistence df

filename <- "site_persist_cleaned.csv"
filename <- here::here("data-raw",
                  "data-raw-mencia",
                  "mencia_site_persistence",
                  filename)

sp <- read.csv(file = filename)

Order sites by age

sp$site <- factor(sp$site,
                      levels = c("La Cueva",
                                 "La Caoba",
                                 "Morelia",
                                 "El Corral"))

Cast for demographic summaries

Identify first instance of bird occuring. (I checked - all birds have the same age code even if recaptured; recaps rare regardless)

i.unique <- match(unique(sp$band),sp$band)

length(unique(sp$band))
length(i.unique)

length(which(duplicated(sp$band) == TRUE))

cast by age

age.cast <- dcast(data= sp[i.unique,],
      formula = species + status ~ site,
      value.var = "site",
      fun.aggregate = length)


age.cast[which(age.cast$status == "mig"), ]

cast by sex

sex.cast <- dcast(data= sp[i.unique,],
      formula = species + status  ~ site + sex,
      value.var = "site",
      fun.aggregate = length)


sex.cast[which(sex.cast$status == "mig"), ]


brouwern/DRmencia documentation built on May 6, 2019, 12:24 p.m.