# Toy example with Pacific Wren sample data
# First, stratify the sample data
strat_data <- stratify(by = "bbs_cws", sample_data = TRUE)
# Prepare the stratified data for use in a JAGS model.
jags_data <- prepare_jags_data(strat_data = strat_data,
species_to_run = "Pacific Wren",
model = "firstdiff",
min_year = 2009,
max_year = 2018)
# Now run a JAGS model.
jags_mod <- run_model(jags_data = jags_data,
n_adapt = 0,
n_burnin = 0,
n_iter = 10,
n_thin = 1)
# Generate the stratum indices
indices <- generate_indices(jags_mod = jags_mod,
jags_data = jags_data,
regions = c("stratum"))
# Now make the geofacet plot.
gp <- geofacet_plot(indices_list = indices,
stratify_by = "bbs_cws",
species = "Pacific Wren",
multiple = TRUE)
# There is an unfortunate conflict between geofacet function in the geofacet package
# and the S3 +.gg method in other ggplot-extension-packages like ggmcmc
# The geofacet_plot function may fail with the following error message:
# Error: Don't know how to add e2 to a plot
# If this happens, you can fix the problem by following these steps
# 1 - save your model output
# 2 - restart your R-session
# 3 - reload the bbsBayes package (do not re-load the other conflicting package, e.g., ggmcmc)
Run the code above in your browser using DataLab