# NOT RUN {
# read and zero-fill the ebd data
f_ebd <- system.file("extdata/zerofill-ex_ebd.txt", package = "auk")
f_smpl <- system.file("extdata/zerofill-ex_sampling.txt", package = "auk")
# data must be for a single species
ebd_zf <- auk_zerofill(x = f_ebd, sampling_events = f_smpl,
species = "Collared Kingfisher",
collapse = TRUE)
occ <- filter_repeat_visits(ebd_zf, n_days = 30)
# format for unmarked
# typically one would join in habitat covariates prior to this step
occ_wide <- format_unmarked_occu(occ,
response = "species_observed",
site_covs = c("latitude", "longitude"),
obs_covs = c("effort_distance_km",
"duration_minutes"))
# create an unmarked object
if (requireNamespace("unmarked", quietly = TRUE)) {
occ_um <- unmarked::formatWide(occ_wide, type = "unmarkedFrameOccu")
unmarked::summary(occ_um)
}
# this function can also be used for abundance modeling
abd <- ebd_zf %>%
# convert count to integer, drop records with no count
dplyr::mutate(observation_count = as.integer(observation_count)) %>%
dplyr::filter(!is.na(observation_count)) %>%
# filter to repeated visits
filter_repeat_visits(n_days = 30)
# prepare for conversion to unmarkedFramePCount object
abd_wide <- format_unmarked_occu(abd,
response = "observation_count",
site_covs = c("latitude", "longitude"),
obs_covs = c("effort_distance_km",
"duration_minutes"))
# create an unmarked object
if (requireNamespace("unmarked", quietly = TRUE)) {
abd_um <- unmarked::formatWide(abd_wide, type = "unmarkedFrameOccu")
unmarked::summary(abd_um)
}
# }
Run the code above in your browser using DataLab