Skip to content

Commit

Permalink
shorten roxygen header. Finalize message. null sensor needed for qpad…
Browse files Browse the repository at this point in the history
…. use native task_duration fixes #50. rebuild. default to remove = none for tidy species.
  • Loading branch information
alexmacphail committed Mar 1, 2024
1 parent 8f8ee57 commit d4c1470
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
21 changes: 13 additions & 8 deletions R/convenience-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
Expand All @@ -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
Expand All @@ -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()

Expand Down Expand Up @@ -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"){
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
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-01T17:57Z
last_built: 2024-03-01T19:29Z
urls:
reference: https://abbiodiversity.github.io/wildRtrax/reference
article: https://abbiodiversity.github.io/wildRtrax/articles
Expand Down
6 changes: 3 additions & 3 deletions man/wt_qpad_offsets.Rd

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

2 changes: 1 addition & 1 deletion man/wt_replace_tmtt.Rd

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

15 changes: 4 additions & 11 deletions man/wt_tidy_species.Rd

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

0 comments on commit d4c1470

Please sign in to comment.