Skip to contents

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

# Start by getting everything you need
Sys.setenv(WT_USERNAME = 'guest', WT_PASSWORD = 'Apple123')
wt_auth()
my_report <- wt_download_report(project_id = 620, sensor_id = 'ARU', reports = "main", weather_cols = F) %>%
  tibble::as_tibble()
#> Downloading: 8.2 kB     Downloading: 8.2 kB     Downloading: 8.2 kB     Downloading: 8.2 kB     Downloading: 8.2 kB     Downloading: 8.2 kB     Downloading: 16 kB     Downloading: 16 kB     Downloading: 16 kB     Downloading: 16 kB     Downloading: 16 kB     Downloading: 16 kB     Downloading: 25 kB     Downloading: 25 kB     Downloading: 25 kB     Downloading: 25 kB     Downloading: 25 kB     Downloading: 25 kB     Downloading: 25 kB     Downloading: 25 kB     Downloading: 33 kB     Downloading: 33 kB     Downloading: 33 kB     Downloading: 33 kB     Downloading: 33 kB     Downloading: 33 kB     Downloading: 41 kB     Downloading: 41 kB     Downloading: 41 kB     Downloading: 41 kB     Downloading: 41 kB     Downloading: 41 kB     Downloading: 43 kB     Downloading: 43 kB     Downloading: 43 kB     Downloading: 43 kB     Downloading: 43 kB     Downloading: 43 kB     Downloading: 43 kB     Downloading: 43 kB

Data wrangling

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

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

# Difference in rows
round((nrow(my_tidy_data)/nrow(my_report)),2)
#> [1] 0.85

So about 15% of detections were mammals. Next, convert TMTT (too many to tag) 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)
#> # A tibble: 6 × 77
#>   organization project_id location  location_id location_buffer_m longitude
#>   <chr>             <dbl> <chr>           <dbl> <lgl>                 <dbl>
#> 1 BU                  620 CHPP-WP-1       94515 NA                    -110.
#> 2 BU                  620 CHPP-WP-1       94515 NA                    -110.
#> 3 BU                  620 CHPP-WP-1       94515 NA                    -110.
#> 4 BU                  620 CHPP-WP-1       94515 NA                    -110.
#> 5 BU                  620 CHPP-WP-2       94518 NA                    -110.
#> 6 BU                  620 CHPP-WP-2       94518 NA                    -110.
#> # ℹ 71 more variables: latitude <dbl>, equipment_make <lgl>,
#> #   equipment_model <lgl>, recording_id <dbl>, recording_date_time <dttm>,
#> #   task_id <dbl>, aru_task_status <chr>, task_duration <dbl>,
#> #   task_method <chr>, AMCR <dbl>, AMRE <dbl>, AMRO <dbl>, BAOR <dbl>,
#> #   BBMA <dbl>, BCCH <dbl>, BHCO <dbl>, BHGR <dbl>, CANG <dbl>, CEDW <dbl>,
#> #   CHSP <dbl>, CONI <dbl>, COPO <dbl>, CORA <dbl>, COYE <dbl>, DEJU <dbl>,
#> #   DUFL <dbl>, EAPH <dbl>, GCKI <dbl>, GHOW <dbl>, HAWO <dbl>, HOWR <dbl>, …

Offsets

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

my_offset_data <- wt_qpad_offsets(data = my_wide_data, species = "all", version = 3, together = TRUE)
#> Extracting covariates for offset calculation. This may take a moment.
#> Loading QPAD estimates... BAM QPAD parameter estimates loaded, version 3 
#> 
#> Calculating offsets...
#>  AMCR
#>  AMRE
#>  AMRO
#>  BAOR
#>  BBMA
#>  BCCH
#>  BHCO
#>  CEDW
#>  CHSP
#>  CORA
#>  COYE
#>  DEJU
#>  DUFL
#>  EAPH
#>  GCKI
#>  HAWO
#>  HOWR
#>  LEFL
#>  LISP
#>  MODO
#>  OCWA
#>  PISI
#>  RBNU
#>  RCKI
#>  RECR
#>  RTHU
#>  SAVS
#>  SWTH
#>  TEWA
#>  TRES
#>  VEER
#>  WAVI
#>  WBNU
#>  WCSP
#>  WEWP
#>  WISN
#>  YBSA
#>  YEWA
#>  YRWA

head(my_offset_data)
#>   organization project_id  location location_id location_buffer_m longitude
#> 1           BU        620 CHPP-WP-1       94515                NA -110.2968
#> 2           BU        620 CHPP-WP-1       94515                NA -110.2968
#> 3           BU        620 CHPP-WP-1       94515                NA -110.2968
#> 4           BU        620 CHPP-WP-1       94515                NA -110.2968
#> 5           BU        620 CHPP-WP-2       94518                NA -110.2974
#> 6           BU        620 CHPP-WP-2       94518                NA -110.2974
#>   latitude equipment_make equipment_model recording_id recording_date_time
#> 1 49.65529             NA              NA       211651 2021-07-05 04:32:00
#> 2 49.65529             NA              NA       211677 2021-07-09 06:06:00
#> 3 49.65529             NA              NA       211676 2021-07-10 05:07:00
#> 4 49.65529             NA              NA       211662 2021-07-10 22:10:00
#> 5 49.65272             NA              NA       211669 2021-07-04 02:40:00
#> 6 49.65272             NA              NA       285273 2021-07-05 02:40:00
#>   task_id aru_task_status task_duration task_method AMCR AMRE AMRO BAOR BBMA
#> 1  180890     Transcribed           180        1SPT    0    0    0    0    0
#> 2  180916     Transcribed           180        1SPT    0    0    0    0    0
#> 3  180915     Transcribed           180        1SPT    1    1    4    0    1
#> 4  180901     Transcribed           180        1SPT    0    0    1    0    0
#> 5  180908     Transcribed           180        1SPT    0    0    0    0    0
#> 6  264441     Transcribed           180        1SPT    0    0    0    0    0
#>   BCCH BHCO BHGR CANG CEDW CHSP CONI COPO CORA COYE DEJU DUFL EAPH GCKI GHOW
#> 1    0    0    1    0    0    0    0    0    2    0    0    0    0    0    1
#> 2    0    0    1    0    0    1    0    0    0    0    0    0    0    0    0
#> 3    0    0    0    0    0    0    0    0    2    0    1    0    0    0    0
#> 4    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
#> 5    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
#> 6    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
#>   HAWO HOWR LAZB LEFL LIBA LIRA LISP LITF LIWI MGWA MOBA MODO MORA MOWI OCWA
#> 1    0    0    0    2    0    0    0    0    0    0    0    1    0    0    0
#> 2    0    3    1    2    0    0    0    0    0    0    0    0    0    0    0
#> 3    0    2    0    1    0    0    0    0    0    0    0    1    0    0    0
#> 4    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
#> 5    0    0    0    0    0    0    0    0    1    0    0    0    0    0    0
#> 6    0    0    0    0    0    1    0    0    0    0    0    0    0    1    0
#>   PISI RBNU RCKI RECR RNSA RTHU SAVS SWTH TEWA TRES UNBI UNKN UNPA UNSA UNTR
#> 1    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
#> 2    0    2    0    0    0    0    0    0    0    0    0    0    0    0    0
#> 3    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
#> 4    0    0    0    0    0    1    0    0    0    0    0    0    0    0    0
#> 5    0    0    0    0    0    0    0    0    0    0    0    0    0    0    1
#> 6    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
#>   UNWA UNWX UPCH VEER WAVI WBNU WCSP WEWP WISN YBSA YEWA YRWA AMCR.off
#> 1    0    0    0    1    0    0    2    1    1    0    0    0 2.370102
#> 2    0    0    0    1    0    0    2    1    0    0    2    0 2.370102
#> 3    0    0    0    1    1    0    1    1    0    0    1    0 2.370102
#> 4    0    0    0    0    0    0    0    0    0    0    0    0 2.369905
#> 5    0    0    0    0    0    0    0    0    0    0    0    0 2.370102
#> 6    0    0    0    0    0    0    0    0    0    0    0    0 2.370102
#>    AMRE.off  AMRO.off  BAOR.off   BBMA.off  BCCH.off  BHCO.off   CEDW.off
#> 1 0.4167774 1.0271415 0.7239005   2.542484 0.3703048 0.1061239 0.05242081
#> 2 0.4167774 1.0271415 0.7239005   2.542484 0.3703048 0.1061239 0.05242081
#> 3 0.4167774 1.0271415 0.7239005   2.542484 0.3703048 0.1061239 0.05242081
#> 4 0.4078807 0.3843135 0.7239005 -14.091866 0.3703048 0.1061239 0.05242081
#> 5 0.4167774 1.0271415 0.7239005   2.537825 0.3703048 0.1061239 0.05242081
#> 6 0.4167774 1.0271415 0.7239005   2.537478 0.3703048 0.1061239 0.05242081
#>    CHSP.off  CORA.off  COYE.off   DEJU.off  DUFL.off  EAPH.off   GCKI.off
#> 1 0.5916778  1.972791 0.8977079  0.9107690 0.1678111 0.9805074 -0.5905164
#> 2 0.5916778  1.972791 0.8977079  0.9107690 0.1678111 0.9805074 -0.5905164
#> 3 0.5916778  1.972791 0.8977079  0.9107690 0.1678111 0.9805074 -0.5905164
#> 4 0.5916778 -1.506756 0.8976880 -0.2123905 0.1678111 0.9805074 -1.2850892
#> 5 0.5916778  1.972791 0.8977079  0.9107690 0.1678111 0.9805074 -0.5905167
#> 6 0.5916778  1.972791 0.8977079  0.9107690 0.1678111 0.9805074 -0.5905167
#>    HAWO.off  HOWR.off   LEFL.off   LISP.off MODO.off  OCWA.off   PISI.off
#> 1 0.4959508  1.083148 0.06602909  0.8481771 1.195639 0.6732180  0.1894495
#> 2 0.4959508  1.083148 0.06602909  0.8481771 1.195639 0.6732178  0.1894495
#> 3 0.4959508  1.083148 0.06602909  0.8481771 1.195639 0.6732158  0.1894495
#> 4 0.4959508 -1.376223 0.06590519 -2.3580608 1.109186 0.6732180 -5.6283000
#> 5 0.4959508  1.083148 0.06602909  0.8481771 1.195639 0.6732178  0.1894495
#> 6 0.4959508  1.083148 0.06602909  0.8481771 1.195639 0.6732176  0.1894495
#>    RBNU.off RCKI.off   RECR.off  RTHU.off   SAVS.off  SWTH.off TEWA.off
#> 1 0.7345163 1.092762 0.08661238 -2.474842  0.9633483 1.1630042 0.271135
#> 2 0.7345163 1.092710 0.08661238 -2.474842  0.9633483 1.1630042 0.271135
#> 3 0.7345163 1.092650 0.08661238 -2.474842  0.9633483 1.1630042 0.271135
#> 4 0.7345163 1.090702 0.08661238 -2.474842 -1.3818771 0.8410931 0.271135
#> 5 0.7345163 1.092762 0.08661238 -2.474842  0.9633483 1.1630042 0.271135
#> 6 0.7345163 1.092762 0.08661238 -2.474842  0.9633483 1.1630042 0.271135
#>    TRES.off VEER.off  WAVI.off  WBNU.off WCSP.off  WEWP.off WISN.off  YBSA.off
#> 1  1.020597 1.310133 0.3371337 0.6905176 1.277016 0.8691736 1.917213 0.8460558
#> 2  1.020597 1.310133 0.3371337 0.6905176 1.277016 0.8691736 1.917213 0.8460558
#> 3  1.020597 1.310133 0.3371337 0.6905176 1.277016 0.8691736 1.917213 0.8460558
#> 4 -3.446437 1.310133 0.3371337 0.6905176 1.277016 0.8691736 1.917213 0.8460557
#> 5  1.020597 1.310133 0.3371337 0.6905176 1.277016 0.8691736 1.917213 0.8460558
#> 6  1.020597 1.310133 0.3371337 0.6905176 1.277016 0.8691736 1.917213 0.8460558
#>    YEWA.off  YRWA.off
#> 1  0.441793 0.3537681
#> 2  0.441793 0.3537681
#> 3  0.441793 0.3537681
#> 4 -4.234049 0.2395314
#> 5  0.441793 0.3537681
#> 6  0.441793 0.3537681

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="OVEN", siteCovs=NULL)
mod <- unmarked::occu(~ 1 ~ 1, dat.occu)
mod
#> 
#> Call:
#> unmarked::occu(formula = ~1 ~ 1, data = dat.occu)
#> 
#> Occupancy:
#>  Estimate  SE   z P(>|z|)
#>     -16.7 NaN NaN     NaN
#> 
#> Detection:
#>  Estimate  SE   z P(>|z|)
#>     -6.46 NaN NaN     NaN
#> 
#> AIC: 4