The recommended workflow to wrangle together data for analysis in wildRtrax is as follows. Once you have your data from wt_download_report().

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = '#>'
)

load("package.RData")
# Attach package
library(wildRtrax)
library(tidyverse)
# Start by getting everything you need
Sys.setenv(WT_USERNAME = 'guest', WT_PASSWORD = 'Apple123')
wt_auth()
my_report <- wt_download_report(project_id = 605, sensor_id = 'ARU', reports = "main", weather_cols = F) %>%
  tibble::as_tibble()

Data wrangling

Now let's start cleaning things up a bit. We don't need certain abiotic codes so let's remove those with wt_tidy_species(),

my_tidy_data <- wt_tidy_species(my_report, remove = "mammal", zerofill=F)

# Difference in rows
round((nrow(my_tidy_data)/nrow(my_report)),2)

So about 5% of detections were mammals. Next, convert TMTT counts to numeric:

my_tmtt_data <- wt_replace_tmtt(data = my_tidy_data, calc = "round")

and finally widen the data into a species matrix.

my_wide_data <- wt_make_wide(data = my_tmtt_data, sound = "all")

head(my_wide_data)

Offsets

Now you can calculate statistical offsets to account for imperfection detection following the QPAD method.

my_offset_data <- wt_qpad_offsets(data = my_wide_data, species = "all", version = 3, together = TRUE)

head(my_offset_data)

Occupancy modelling

You can also perform a single-season, single-species occupancy work flow using wt_format_occupancy() once the data is downloaded.

dat.occu <- wt_format_occupancy(my_report, species="WTSP", siteCovs=NULL)
mod <- unmarked::occu(~ 1 ~ 1, dat.occu)
mod


mabecker89/wildRtrax documentation built on Feb. 5, 2024, 8:50 a.m.