Skip to content

Commit

Permalink
test build v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmacphail committed Mar 27, 2024
1 parent e2b364f commit e6ff162
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ VignetteBuilder: knitr
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Config/testthat/edition: 3
URL: https://abbiodiversity.github.io/wildRtrax/
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import(pipeR)
import(progressr)
import(purrr)
import(readr)
import(rlang)
import(seewave)
import(sf)
import(stringr)
Expand Down
5 changes: 2 additions & 3 deletions R/acoustic-pre-processing.R
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ wt_signal_level <- function(path, fmin = 500, fmax = NA, threshold, channel = "l
#'
#' @description "Chops" up wav files into many smaller files of a desired duration
#'
#' @param input A \code{`wt_audio_scanner`} tibble of files
#' @param input A data frame or tibble containing information about audio files
#' @param segment_length Numeric; Segment length in seconds. Modulo recording will be exported should there be any trailing time left depending on the segment length used
#' @param output_folder Character; output path to where the segments will be stored
#'
Expand All @@ -608,8 +608,7 @@ wt_signal_level <- function(path, fmin = 500, fmax = NA, threshold, channel = "l
#'
#' @examples
#' \dontrun{
#' wt_chop(input = my_audio_tibble,
#' segment_length = 60, output_folder "/where/i/store/my/chopped/files")
#' wt_chop(input = my_files, segment_length = 60, output_folder = "output_folder")
#' }
#'
#' @return Segmented files written to the output_folder
Expand Down
6 changes: 3 additions & 3 deletions R/analyze-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' @param detection_id_col Defaults to `detection`. The column indicating the detection id
#' @param start_col_det Defaults to `start_time`. The column indicating the start time of the independent detections
#'
#' @import dplyr lubridate tidyr
#' @import dplyr lubridate tidyr rlang
#' @export
#'
#' @examples
Expand Down Expand Up @@ -203,7 +203,7 @@ wt_summarise_cam <- function(detect_data, raw_data, time_interval = "day",
#' @param remove_human Logical; Should human and human-related tags (e.g. vehicles) be removed? Defaults to TRUE.
#' @param remove_domestic Logical; Should domestic animal tags (e.g. cows) be removed? Defaults to TRUE.
#'
#' @import dplyr lubridate
#' @import dplyr lubridate rlang
#' @export
#'
#' @examples
Expand All @@ -213,7 +213,7 @@ wt_summarise_cam <- function(detect_data, raw_data, time_interval = "day",
#'
#' @return A dataframe of independent detections in your camera data, based on the threshold you specified. The df wil include information about the duration of each detection, the number of images, the average number of individual animals per image, and the max number of animals in the detection.

wt_ind_detect <- function(x, threshold, units = "minutes", datetime_col = image_date_time, remove_human = TRUE, remove_domestic = TRUE) {
wt_ind_detect <- function(x, threshold, units = "minutes", datetime_col = image_date_time, remove_human = TRUE, remove_domestic = TRUE) {

# Check that x is a dataframe
if (!is.data.frame(x)) {
Expand Down
3 changes: 2 additions & 1 deletion R/convenience-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ wt_tidy_species <- function(data,
#'
#' @param data Dataframe of WildTrax observations, for example the summary report.
#' @param calc Character; method to convert model predictions to integer ("round", "ceiling", or "floor"). See `?round()` for details.
#' @import dplyr
#'
#' @import dplyr tidyr
#' @export
#'
#' @examples
Expand Down
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ articles:
camera-data-wrangling: camera-data-wrangling.html
introduction: introduction.html
tutorials: tutorials.html
last_built: 2024-03-21T17:59Z
last_built: 2024-03-27T14:40Z
urls:
reference: https://abbiodiversity.github.io/wildRtrax/reference
article: https://abbiodiversity.github.io/wildRtrax/articles
Expand Down
2 changes: 1 addition & 1 deletion man/wildRtrax.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/wt_chop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-aru.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test_that("Authentication works correctly", {

test_that("Downloading ARU report", {
cypress_hills_aru <- wt_download_report(620, 'ARU', 'tag', FALSE)
expect_true(!is.null(cypress_hills))
expect_true(!is.null(cypress_hills_aru))
})

test_that("Testing a Private Project", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-cam.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test_that("Downloading CAM report", {

test_that("Individual detections", {
abmi_amph_cam <- wt_download_report(391, 'CAM', 'main', FALSE)
ind_detections <- wt_ind_detect(abmi_amph_cam, threshold, units = "minutes", datetime_col = image_date_time, remove_human = TRUE, remove_domestic = TRUE)
ind_detections <- wt_ind_detect(abmi_amph_cam, threshold = 60, units = "minutes", datetime_col = image_date_time, remove_human = TRUE, remove_domestic = TRUE)
expect_true(nrow(abmi_amph_cam) > nrow(ind_detections))

})
Expand Down
Binary file modified vignettes/package.RData
Binary file not shown.
38 changes: 19 additions & 19 deletions vignettes/tutorials.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,34 @@ data <- wt_download_report(620,'ARU',c('birdnet','main'),F)

When downloading multiple reports, the `data` object then becomes a list of tibbles. The results from the `main` report can then be anti-joined against the `birdnet` report to determine if any species were detected than a human did not find. It's recommended to use high threshold values from BirdNET and species that should occur or be allowed in the project.

```{r, eval=F, include=T, message=F, warning=F}
library(tidyverse)
```{r, eval=T, include=T, message=F, warning=F}
birdnet_report <- data[[1]] %>%
birdnet_report <- data[[1]] |>
dplyr::filter(is_species_allowed_in_project == 't',
confidence > 50) %>%
tibble::add_column(observer = 'BirdNET') %>%
dplyr::select(location, recording_date_time, observer, species_code) %>%
confidence > 50) |>
tibble::add_column(observer = 'BirdNET') |>
dplyr::select(location, recording_date_time, observer, species_code) |>
dplyr::distinct()
main_report <- data[[2]] %>%
wt_tidy_species(remove = c("mammal", "amphibian", "abiotic", "insect"), zerofill = F) %>%
dplyr::select(location, recording_date_time, observer, species_code) %>%
main_report <- data[[2]] |>
wt_tidy_species(remove = c("mammal", "amphibian", "abiotic", "insect"), zerofill = F) |>
dplyr::select(location, recording_date_time, observer, species_code) |>
dplyr::distinct()
merged_data <- dplyr::bind_rows(birdnet_report, main_report) %>% dplyr::arrange(location, recording_date_time) %>%
dplyr::group_by(location, recording_date_time, observer, species_code) %>%
dplyr::mutate(presence = dplyr::row_number()) %>%
dplyr::ungroup() %>%
tidyr::pivot_wider(names_from = species_code, values_from = presence, values_fill = 0) %>%
merged_data <- dplyr::bind_rows(birdnet_report, main_report) |>
dplyr::arrange(location, recording_date_time) |>
dplyr::group_by(location, recording_date_time, observer, species_code) |>
dplyr::mutate(presence = dplyr::row_number()) |>
dplyr::ungroup() |>
tidyr::pivot_wider(names_from = species_code, values_from = presence, values_fill = 0) |>
tidyr::pivot_longer(cols = -c(location, recording_date_time, observer), names_to = "species_code", values_to = "presence")
missing_detections <- merged_data %>%
dplyr::filter(observer == "BirdNET" & presence == 1) %>%
dplyr::select(location, recording_date_time, species_code) %>%
missing_detections <- merged_data |>
dplyr::filter(observer == "BirdNET" & presence == 1) |>
dplyr::select(location, recording_date_time, species_code) |>
dplyr::anti_join(
merged_data %>%
dplyr::filter(observer != "BirdNET") %>%
merged_data |>
dplyr::filter(observer != "BirdNET") |>
dplyr::select(location, recording_date_time, species_code, presence),
by = c("location", "recording_date_time", "species_code")
)
Expand Down

0 comments on commit e6ff162

Please sign in to comment.