Skip to content

Commit

Permalink
make extractSignals and extractCodeSpaces much faster
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomflavio committed Feb 20, 2025
1 parent 9d792ad commit 389b4d0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: actel
Title: Acoustic Telemetry Data Analysis
Version: 1.3.0.9018
Version: 1.3.0.9019
Authors@R: c(
person("Hugo", "Flávio", role = c("aut", "cre"),
email = "[email protected]", comment = c(ORCID = "0000-0002-5174-1197")),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Enhancements:
* Improved internal mechanisms for message/warning/debug/stop reporting. new internal function `event()` replaces the old `appendTo()`, `stopAndReport()`, and `emergencyBreak()` (issue [#135](https://github.com/hugomflavio/actel/issues/135))
* Added the ability to use output of `loadSpatial()` as 'starters' for `distancesMatrix()` when 'actel' is 'TRUE'. This allows a user to input their spatial.csv if located in a separate working directory (issue [#133](https://github.com/hugomflavio/actel/issues/133))
* Distance matrix is now retained in the output of `explore()`, `residency()`, and `migration()` analysis when invalid. Additionally, if the distance matrix is not available NA will be denoted in the output. (issue [#142](https://github.com/hugomflavio/actel/issues/142))
* Improved the inner mechanics of `extractSignals()` and `extractCodeSpaces()` so they're much faster now.

## actel 1.3.0

Expand Down
10 changes: 4 additions & 6 deletions R/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,8 @@ dataToList <- function(source){
#' @export
#'
extractSignals <- function(input) {
output <- lapply(input, function(x) {
aux <- unlist(strsplit(as.character(x), "-"))
return(as.numeric(tail(aux, 1)))
})
return(unlist(output))
output <- stringr::str_extract(input, "(?<=-)[^-]*$")
return(as.numeric(output))
}

#' Extract Code Spaces from transmitter names
Expand All @@ -314,7 +311,8 @@ extractSignals <- function(input) {
#' @export
#'
extractCodeSpaces <- function(input) {
unname(sapply(input, function(x) sub("-[0-9]*$", "", as.character(x))))
output <- stringr::str_extract(input, ".*(?=-)")
return(output)
}


Expand Down

0 comments on commit 389b4d0

Please sign in to comment.