From d4c147099c2aa925374f1df8d13bbb20c94e843c Mon Sep 17 00:00:00 2001 From: agmacpha Date: Fri, 1 Mar 2024 14:12:02 -0700 Subject: [PATCH] shorten roxygen header. Finalize message. null sensor needed for qpad. use native task_duration fixes #50. rebuild. default to remove = none for tidy species. --- R/convenience-functions.R | 21 +++++++++++++-------- R/utils.R | 2 +- docs/pkgdown.yml | 2 +- man/wt_qpad_offsets.Rd | 6 +++--- man/wt_replace_tmtt.Rd | 2 +- man/wt_tidy_species.Rd | 15 ++++----------- 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/R/convenience-functions.R b/R/convenience-functions.R index 7cbed99..60745fd 100644 --- a/R/convenience-functions.R +++ b/R/convenience-functions.R @@ -92,19 +92,24 @@ wt_location_distances <- function(input_from_tibble = NULL, input_from_file = NU #' #' @examples #' \dontrun{ -#' dat.tidy <- wt_tidy_species(dat, remove=c("mammal", "bird", "amphibian", "abiotic", "insect", "human", "unknown"), zerofill = T, sensor = 'ARU')} +#' dat.tidy <- wt_tidy_species(dat, remove=c("mammal", "unknown"), +#' zerofill = T, sensor = 'ARU')} #' @return A dataframe identical to input with observations of the specified groups removed. wt_tidy_species <- function(data, - remove = c("mammal", "bird", "amphibian", "abiotic", "insect", "human", "unknown"), + remove = "", zerofill = TRUE, sensor = c("ARU","PC")) { + if (is.null(remove)) { + remove <- "" + message('Not removing any species') + } + if (any(!(remove %in% c("mammal", "bird", "amphibian", "abiotic", "insect", "human", "unknown")))) { stop("Select one remove option from bird, mammal, amphibian, abiotic, insect, human or unknown.") } - if (!(sensor %in% c("ARU","PC"))){ stop("Select one sensor option from ARU or PC.") } @@ -117,7 +122,7 @@ wt_tidy_species <- function(data, } if('bird' %in% remove){ - message('Note that there are only QPAD offsets for birds.') + message('Note: By removing birds, you will not be able to use wt_qpad_offsets since QPAD offsets are only available for birds.') } #Convert to the sql database labels for species class @@ -127,7 +132,7 @@ wt_tidy_species <- function(data, remove=="insect" ~ "INSECTA", remove=="bird" ~ "AVES", remove=="human" ~ "HUMAN ACTIVITY", - !is.na(remove) ~ remove) + remove=="" ~ remove) .species <- wt_get_species() @@ -479,11 +484,11 @@ wt_format_occupancy <- function(data, #' dat.clean <- wt_tidy_species(dat) #' dat.tmtt <- wt_replace_tmtt(dat.clean) #' dat.wide <- wt_make_wide(dat.tmtt, sound="all") -#' dat.qpad <- wt_qpad_offsets(dat.wide, species="all", version=3, together = TRUE) +#' dat.qpad <- wt_qpad_offsets(dat.wide, species="all", version=3, together = TRUE, sensor = "ARU") #' } -#' @return An object of class unmarkedFrameOccu. See `unmarked::unmarkedFrameOccu` for details. +#' @return A dataframe containing the QPAD values either by themselves or with the original wide data if together = T -wt_qpad_offsets <- function(data, species = c("all"), version = 3, together=FALSE, sensor="ARU"){ +wt_qpad_offsets <- function(data, species = c("all"), version = 3, together=FALSE, sensor="") { #Rename fields if PC if(sensor=="PC"){ diff --git a/R/utils.R b/R/utils.R index 982a0df..cb2d276 100644 --- a/R/utils.R +++ b/R/utils.R @@ -157,7 +157,7 @@ time <- str_sub(data$recording_date_time, 12, 19) lon <- as.numeric(data$longitude) lat <- as.numeric(data$latitude) - dur <- as.numeric(str_sub(data$task_duration, -100, -2)) + dur <- as.numeric(data$task_duration) dis <- Inf #parse date+time into POSIXlt diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index cf8731f..1d5af15 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -9,7 +9,7 @@ articles: camera-data-wrangling: camera-data-wrangling.html introduction: introduction.html tutorials: tutorials.html -last_built: 2024-03-01T17:57Z +last_built: 2024-03-01T19:29Z urls: reference: https://abbiodiversity.github.io/wildRtrax/reference article: https://abbiodiversity.github.io/wildRtrax/articles diff --git a/man/wt_qpad_offsets.Rd b/man/wt_qpad_offsets.Rd index a29a310..c83e81f 100644 --- a/man/wt_qpad_offsets.Rd +++ b/man/wt_qpad_offsets.Rd @@ -9,7 +9,7 @@ wt_qpad_offsets( species = c("all"), version = 3, together = FALSE, - sensor = "ARU" + sensor = "" ) } \arguments{ @@ -24,7 +24,7 @@ wt_qpad_offsets( \item{sensor}{Character; can be one of "ARU" or "PC"} } \value{ -An object of class unmarkedFrameOccu. See \code{unmarked::unmarkedFrameOccu} for details. +A dataframe containing the QPAD values either by themselves or with the original wide data if together = T } \description{ This function calculates statistical offsets that account for survey-specific and species-specific variation in availability for detection and perceptibility of birds. This function requires download of the \code{QPAD} R package and should be used on the output of the \code{wt_format_wide} function @@ -36,7 +36,7 @@ devtools::install_github("borealbirds/QPAD") dat.clean <- wt_tidy_species(dat) dat.tmtt <- wt_replace_tmtt(dat.clean) dat.wide <- wt_make_wide(dat.tmtt, sound="all") -dat.qpad <- wt_qpad_offsets(dat.wide, species="all", version=3, together = TRUE) +dat.qpad <- wt_qpad_offsets(dat.wide, species="all", version=3, together = TRUE, sensor = "ARU") } } \references{ diff --git a/man/wt_replace_tmtt.Rd b/man/wt_replace_tmtt.Rd index b00a69b..9d7c1b0 100644 --- a/man/wt_replace_tmtt.Rd +++ b/man/wt_replace_tmtt.Rd @@ -19,6 +19,6 @@ This function uses a lookup table of model-predicted values to replace 'TMTT' en } \examples{ \dontrun{ -dat.tmtt <- wt_replace_tmtt(dat, calc="round") +dat.tmtt <- wt_replace_tmtt(data, calc="round") } } diff --git a/man/wt_tidy_species.Rd b/man/wt_tidy_species.Rd index ab365a0..dfa0082 100644 --- a/man/wt_tidy_species.Rd +++ b/man/wt_tidy_species.Rd @@ -4,17 +4,12 @@ \alias{wt_tidy_species} \title{Filter species from a report} \usage{ -wt_tidy_species( - data, - remove = c("mammal", "amphibian", "abiotic", "insect", "unknown"), - zerofill = TRUE, - sensor = c("ARU", "PC") -) +wt_tidy_species(data, remove = "", zerofill = TRUE, sensor = c("ARU", "PC")) } \arguments{ \item{data}{WildTrax main report or tag report from the \code{wt_download_report()} function.} -\item{remove}{Character; groups to filter from the report ("mammal", "bird", "amphibian", "abiotic", "insect", "unknown"). Defaults to retaining bird group only.} +\item{remove}{Character; groups to filter from the report ("mammal", "bird", "amphibian", "abiotic", "insect", "human", "unknown"). Defaults to retaining bird group only.} \item{zerofill}{Logical; indicates if zerofilling should be completed. If TRUE, unique surveys with no observations after filtering are added to the dataset with "NONE" as the value for species_code and/or species_common_name. If FALSE, only surveys with observations of the retained groups are returned. Default is TRUE.} @@ -28,8 +23,6 @@ This function filters the species provided in WildTrax reports to only the group } \examples{ \dontrun{ -dat.tidy <- wt_tidy_species(dat, -remove=c("mammal", "amphibian", "abiotic", "insect", "unknown"), -zerofill = TRUE) -} +dat.tidy <- wt_tidy_species(dat, remove=c("mammal", "unknown"), +zerofill = T, sensor = 'ARU')} }